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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
TP129
Frequent Visitor

Calculate YOY variance of distributions

Hi everyone,

 

I was hoping someone could help me out here. I wanted to calculate the distributions as follows:

    (1) percent of column total this year

    (2) percent of column total last year

    (3) YOY variance = (1) – (2)

 

Here are my formulas:

 

For (1): DIVIDE(SUM(Table1[Total]), CALCULATE(SUM(Table1[Total]), ALLSELECTED(‘Table2’[Level], ‘Table2’[Index]))) ---- I want to sort Level by Index

 

For (2): CALCULATE(DIVIDE(SUM(Table1[Total]), CALCULATE(SUM(Table1[Total]), ALLSELECTED(‘Table2’[Level], ‘Table2’[Index]))), FILTER(‘Date’, ‘Date’[Year] = MAX(‘Date’[Year]) – 1)) ---- basically just calculate (1), filtered for last year

 

I’ve attached a screenshot here and you can see I have a slicer next to my matrix. If I remove filter for 2021, my (2) formula works fine and I get the results for 2020. But if I choose 2021, my (2) still returns results for 2021. I’m not allowed to remove filter for 2021, it has to be there since I will have other tables on my report. How can I get my 2020 results then?

 

Screen Shot 2021-09-08 at 4.30.50 PM.png

 

Another screenshot is the expected results for 2020 (you can ignore the number of months in each year)

 

Screen Shot 2021-09-08 at 4.50.08 PM.png

My ultimate goal is to get the YOY variance (3). However, it didn’t work when I used the built-in formula for percent of column total. If someone could also help me with the built-in formula that would be great. If it's not possible to use it, I will continue to work around using DAX as above.

 

I really appreciate all your help and let me know if you need any further info.

 

Best,

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@TP129 , Try like

 

CALCULATE( DIVIDE(SUM(Table1[Total]), CALCULATE(SUM(Table1[Total]), ALLSELECTED(‘Table2’[Level], ‘Table2’[Index]))) , FILTER(all('Date'), 'Date'[Year] = MAX('Date'[Year])) )

 

For (2):

 

CALCULATE(DIVIDE(SUM(Table1[Total]), CALCULATE(SUM(Table1[Total]), ALLSELECTED(‘Table2’[Level], ‘Table2’[Index]))), FILTER(all('Date'), 'Date'[Year] = MAX('Date'[Year]) – 1))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@TP129 , Try like

 

CALCULATE( DIVIDE(SUM(Table1[Total]), CALCULATE(SUM(Table1[Total]), ALLSELECTED(‘Table2’[Level], ‘Table2’[Index]))) , FILTER(all('Date'), 'Date'[Year] = MAX('Date'[Year])) )

 

For (2):

 

CALCULATE(DIVIDE(SUM(Table1[Total]), CALCULATE(SUM(Table1[Total]), ALLSELECTED(‘Table2’[Level], ‘Table2’[Index]))), FILTER(all('Date'), 'Date'[Year] = MAX('Date'[Year]) – 1))

Thank you so much! It works now. 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.