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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
joan-la
New Member

All Referencing a measure in another measure

joanla_0-1632777285662.png

 

Is there a way I can use ALL or other dax formula to apply a page filter only in the first 2 columns but exclude it from the last 2 columns which are measures (QTDs)? 

 

Thanks!

 

3 REPLIES 3
colacan
Resolver II
Resolver II

@joan-la Hi joan,

You might think CALCULATE(SUM(Query[Revenue]),Query[Fiscal Week]="2021-W14") as 
"if Query[Fiscal Week] ="2021-W14" then calculate..." expecting it will return 0 if [Fiscal Week] is not "2021-W14".

That is not ture. 

Actually, CALCULATE(SUM(Query[Revenue]),Query[Fiscal Week]="2021-W14" means whatever outter filter is(from your filter page), provide the value of SUM(Query[Revenue] when [Fiscal Week]="2021-W14" which is 3 in your example. that's why you always get the same answer regardless your filter.

If you want to get QTD based on your selected week you can simply use TOTALQTD with complate date table related to your Revenue table.

However if you need to keep current way, below code might give you the value you intended. 

VAR W14 = IF(SELECTEDVALUE(Query[Fiscal Week])="2021-W14", SUM(Query[Revenue]),0)

 

hope this helps you.

 

Plesae mark as solution if this resolved your issue.
 

Greg_Deckler
Super User
Super User

@joan-la Theoretically but would need more information. You could use something like CALCULATE([Measure],ALL('Table')) for example. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

This is a sample of what I have

 

Q2 QTD =
VAR W14 = CALCULATE(SUM(Query[Revenue]),Query[Fiscal Week]="2021-W14")
VAR W15 = CALCULATE(SUM(Query[Revenue]),Query[Fiscal Week]="2021-W15")


Var Result = W14+W15
Return
IF(ISBLANK(Result),0,Result)

 

------------------------------------

Lets say that W14= 3  and W15 = 5. I would like to receive 8. 

But I have a page filter of "Fiscal Week" to show specifics one. If I filter by WK 15, WK 16, WK 17 for example. then I will only receive in Q2 QTD  the result of 5 instead of 8.

 

So I will like to apply the page filter "Fiscal Week" to the rest of the table but excluding it from the QTD one so I can receive in this case the 8 value no matter the filters being applied. 

 

Please let me know if this helps or additional information is required

 

Thank you!!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors