dax filter

Anything related to PowerPivot and DAX Formuale
arkiboys
Posts: 3
Joined: Mon May 27, 2019 6:16 pm

dax filter

Postby arkiboys » Sun Jun 16, 2019 2:40 pm

There is a table in model called Currency.
Code is a column in currency table which has currencycodes i.e. GBP, USD, etc...
How can I create a measure by writing dax to show only the following currencies (GBP, USD, EUR) from the code?
I have the following but it is not correct.
Thank you

filterCurrencies = calculate(values('Currency'[Code], 'Currency'[Code] = "USD",'Currency'[Code] = "GBP",'Currency'[Code] = "EUR"))

PhilC
Posts: 274
Joined: Tue Sep 09, 2014 8:13 am

Re: dax filter

Postby PhilC » Sun Jun 16, 2019 9:02 pm

DAX uses the pipe to represent OR.

So, try || (two pipe characters) between the options to include.

You may need to use a FILTER within the CALCULATE depending on how you will use filterCurrencies.

Cheers
Phil

arkiboys
Posts: 3
Joined: Mon May 27, 2019 6:16 pm

Re: dax filter

Postby arkiboys » Mon Jun 17, 2019 2:51 pm

Hi,
Can you let me have the exact DAX as I do not seem to get this to work?
Thank you

PhilC
Posts: 274
Joined: Tue Sep 09, 2014 8:13 am

Re: dax filter

Postby PhilC » Mon Jun 17, 2019 3:51 pm

Hi, if you provide a file with the data model and what you are trying to to, with expected output (mock up data if sensitive) it is more likely specific DAX can be provided.

The DAX you provided is not an actual measure as it has no aggregator function, just the VALUES one (this returns a table), so it would be difficult to provide DAX based on what you have provided so far.

Otherwise, read up on FILTER and on OR in expressions

https://www.youtube.com/watch?v=ewjRItLlgG8
https://www.sqlbi.com/articles/filter-a ... calculate/

https://dax.guide/op/or/

Cheers
Phil

GIBSON
Posts: 1
Joined: Fri Aug 09, 2019 9:40 pm

Re: dax filter

Postby GIBSON » Tue Aug 20, 2019 8:59 pm

Hi everyone,



I want to filter a field. For example, Total sales for every month except June

What I did :

CALCULATE(SUM('Table1'[Sales]);FILTER(ALL('Table1'[Month]);'Table1'[Month]<>"June"))



Great.... but it's a cumulative function.



How can I sum sales with filter without using the panel

Oxenskiold
Posts: 37
Joined: Tue Jan 05, 2016 10:38 pm

Re: dax filter

Postby Oxenskiold » Tue Aug 27, 2019 11:33 pm

You could try:

CALCULATE(SUM('Table1'[Sales]);FILTER(VALUES('Table1'[Month]);'Table1'[Month]<>"June"))

or alternatively

CALCULATE(SUM('Table1'[Sales]);KEEPFILTERS(Table1'[Month]<>"June"))


Return to “PowerPivot/DAX”

Who is online

Users browsing this forum: No registered users and 0 guests