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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Arne
Frequent Visitor

Use measure in filter

Hi need to include a measure into a filter to get dynamic calculations. 

I have started to select the period with a slicer which gives my the period in a measure as below

 

Var Sort order period = SELECTEDVALUE(ProdUnitAnalyzeHyperionDimPeriodView[SortOrderPeriod])

In this example i choose "202002 Actual" in Var Sort order Period.  

Then i would like to get the period value from  the measure "Var Sort order period"

Into the calculation below 

 

CALCULATE(SUM(ProdUnitAnalyzeScorecardView[Amount]);(ProdUnitAnalyzeScorecardView[Account]="SCEBIT");(ProdUnitAnalyzeHyperionDimPeriodView[SortOrderPeriod]=[Var Sort order period]))
/
CALCULATE(SUM(ProdUnitAnalyzeScorecardView[Amount]);(ProdUnitAnalyzeScorecardView[Account]="SC50");(ProdUnitAnalyzeHyperionDimPeriodView[SortOrderPeriod]= [Var Sort order period]))

 

which is not working. 

When i typer in the period "202002 actual" in the measure below it works. but i need to change the period from a slicer to get the diagram to react quickly.

 

CALCULATE(SUM(ProdUnitAnalyzeScorecardView[Amount]);(ProdUnitAnalyzeScorecardView[Account]="SCEBIT");(ProdUnitAnalyzeHyperionDimPeriodView[SortOrderPeriod]="202002 Actual"))
/
CALCULATE(SUM(ProdUnitAnalyzeScorecardView[Amount]);(ProdUnitAnalyzeScorecardView[Account]="SC50");(ProdUnitAnalyzeHyperionDimPeriodView[SortOrderPeriod]="202002 Actual"))

 

Is there any solution on how to do this?

Br

Arne

 

 

 

 

 

 

 

2 REPLIES 2
Greg_Deckler
Super User
Super User

Not following this. 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


@ 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...
Anonymous
Not applicable

[Total Amount] = SUM ( ProdUnitAnalyzeScorecardView[Amount] )


[Your Measure] = 
var __sortOrderPeriod = [Var Sort order period]
var __numerator =
	CALCULATE (
	    [Total Amount],
	    ProdUnitAnalyzeScorecardView[Account] = "SCEBIT",
	    ProdUnitAnalyzeHyperionDimPeriodView[SortOrderPeriod] = __sortOrderPeriod
	)
var __denominator =
    CALCULATE (
        [Total Amount],
        ProdUnitAnalyzeScorecardView[Account] = "SC50",
        ProdUnitAnalyzeHyperionDimPeriodView[SortOrderPeriod] = __sortOrderPeriod
    )
var __result = DIVIDE( __numerator, __denominator )
RETURN
	__result

 

I don't know anything about your model but I'd warn you against slicing directly on your fact table by the users. This is dangerous and may produce incorrect results you'll not even be aware of (since the great majority of people do not check their figures well against the source data). If you want to know why you should not do it, then you can search for an article on www.sqlbi.com; just type in the search box: auto-exist.

 

Best

D

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.