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
Himanshu_1306
Resolver I
Resolver I

Different measure calculations based on Slicer selection

Hi All,

 

I have a situation where I want to use two seperate calculations in a single measure while using the Slicer. 
While selecting the fiscal quarter as Q4(Current) I want to show the pacing using the below calculation

SQO QTD $ Pacing_V2 = DIVIDE([SQO QTD $(Pacing)],[SQO $ QTD Target(Pacing)],0)
 
whereas if user select any other quarter ( which is not current ) I want to use calculation as below

SQO $ QTD Attainment = DIVIDE([SQO $ QTD],[SQO $ FQ Target_G],0)
 
How should I achieve this scenario?
 

Himanshu_1306_0-1703088756037.png

 

Regards,

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

If you add a column in your date table to flag the current FY Quarter (say using a 1 as a flag -let's call this 'Date Table'[FYQ Flag]- , you can then use a simple if clause in the measure to switch calculations:

Selection measure =
IF (
    MAX ( 'Date Table'[FYQ Flag] ) = 1,
    DIVIDE ( [SQO QTD $(Pacing)], [SQO $ QTD Target(Pacing)], 0 ),
    DIVIDE ( [SQO $ QTD], [SQO $ FQ Target_G], 0 )
)

 

(Instead of the flag in the date table you could write the code to establish the current FYQ in a VAR within the measure of course...)

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

Sorry, I'm not following your scenario.. can you provide a sample PBIX file?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






I was able to create a measure to make it work dynamically and got the desired result.

 

Thank you !!!

PaulDBrown
Community Champion
Community Champion

If you add a column in your date table to flag the current FY Quarter (say using a 1 as a flag -let's call this 'Date Table'[FYQ Flag]- , you can then use a simple if clause in the measure to switch calculations:

Selection measure =
IF (
    MAX ( 'Date Table'[FYQ Flag] ) = 1,
    DIVIDE ( [SQO QTD $(Pacing)], [SQO $ QTD Target(Pacing)], 0 ),
    DIVIDE ( [SQO $ QTD], [SQO $ FQ Target_G], 0 )
)

 

(Instead of the flag in the date table you could write the code to establish the current FYQ in a VAR within the measure of course...)

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown Thanks for the update.

 

I'm able to achieve the desired result using the below measure but is there a way to make it dynamic because currenty I will have to change the value of my variable (_CFQ) each quarter .

Also I dont have a flag value as 1 as you mentioned but I do have a column "Rolling Fiscal Quarter" which shows the latest quarter when its 0 so Rolling Fiscal Quarter = 0 will show the latest quarter.

Can we use this to make it dynamic?

Measure:

Selection measure =
VAR _CFQ = CALCULATE(MAX(F_SQO_TARGETS[FISCAL_YEAR_QUARTER]),F_SQO_TARGETS[Current Fiscal year and quarter] = TRUE())
RETURN
IF (
    _CFQ = "FY24 Q4",
    DIVIDE ( [SQO QTD $(Pacing)], [SQO $ QTD Target(Pacing)], 0 ),
    DIVIDE ( [SQO $ QTD], [SQO $ FQ Target_G], 0 )
)

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.