Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Condition ($ <>) in the expression

I have a measure and need to apply it a filter condition when the User filter a month the value of the measure need to be maintained even if the value used in the measure has no relationship with the month table, for example I have the following expression in QlikView: sum ({$ <Month =>} Vl_ReceitaPrevista)
In power bi I have sum (Vl_ReceitaPrevista).


How would I do this in power bi?

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

It sounds like you need an ALL or ALLEXCEPT clause in your SUM calculation. Generally, you do this by wrapping the SUM in a CALCULATE like:

 

CALCULATE(SUM(VI_ReceitaPrevista),ALL(table))

Basically, the ALL and ALLEXCEPT clauses create an context for the SUM that is independent of other contextual filters that may be applied, like from slicers. Can't really get too specific without sample data.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

It sounds like you need an ALL or ALLEXCEPT clause in your SUM calculation. Generally, you do this by wrapping the SUM in a CALCULATE like:

 

CALCULATE(SUM(VI_ReceitaPrevista),ALL(table))

Basically, the ALL and ALLEXCEPT clauses create an context for the SUM that is independent of other contextual filters that may be applied, like from slicers. Can't really get too specific without sample data.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler

Did a test here after I applied the solution, calcaulate function (all ()) solves the problem of being presented zero when filtered dimension in my case a month dimension however when it is filtered a month that there was change and the value is not changed, for example, in January there was no movement and so when filtered it is presented to zero and should be shown the total value of the year with the function all this problem was solved however when I filter the month of February there was drive the still displayed value is the total of the year and in fact should be presented the value of the current year in February.

 

Briefly function cancels all the filter made of the size I expecificar the expression, in this case how could I fix this?

 

Follow my expression:

Budgeted Current = CALCULATE (if (ISBLANK (Sum (Facts [Budgeted Initial]) + Sum (Facts [Vl_Suplementado]) - Sum (Facts [Vl_Reduzido])); 0; (Sum (Facts [Budgeted Initial]) + Sum (Facts [Vl_Suplementado]) - Sum (Facts [Vl_Reduzido]))), ALL (DMEGF_Mes [Month]))

Try changing your ALL to ALLEXCEPT, see documentation here:

https://msdn.microsoft.com/en-us/library/ee634795.aspx

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler

I tried ALL EXCEPT but the displayed value is reset

You may have to add some columns to your ALLEXCEPT clause. It is really difficult to be specific without sample data and your expected output. ALLEXCEPT removes all context filters except for the ones that you specify in the ALLEXCEPT function.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler

That was exactly what I needed, thank you

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.