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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
jayceeb
Frequent Visitor

Variance between filtered date

Hi, How to get the variance for filtered dates.

example :

 

DateTotal
Jan5477604
Feb5469004
  
Variance-8,600

jayceeb_1-1684751188644.png

 

jayceeb_3-1684751359750.png

 

 

1 ACCEPTED SOLUTION

@jayceeb 

Please try

Variance =
VAR MaxMonth =
MAX ( MonthsF[YearMonth] )
VAR MinMonth =
MIN ( MonthsF[YearMonth] )
VAR MaxMonthValue =
CALCULATE ( SUM ( Consumptions[Total] ), MonthsF[YearMonth] = MaxMonth )
VAR MinMonthValue =
CALCULATE ( SUM ( Consumptions[Total] ), MonthsF[YearMonth] = MinMonth )
RETURN
MaxMonthValue - MinMonthValue

View solution in original post

9 REPLIES 9
jayceeb
Frequent Visitor

Hi, I have a Date table shown below.

however I don't know how to get the variance. I'm using only one column for date and I want to select between months. please help

jayceeb_0-1684924116743.png

 

 

@jayceeb 

Please try

Variance =
VAR MaxMonth =
MAX ( MonthsF[YearMonth] )
VAR MinMonth =
MIN ( MonthsF[YearMonth] )
VAR MaxMonthValue =
CALCULATE ( SUM ( Consumptions[Total] ), MonthsF[YearMonth] = MaxMonth )
VAR MinMonthValue =
CALCULATE ( SUM ( Consumptions[Total] ), MonthsF[YearMonth] = MinMonth )
RETURN
MaxMonthValue - MinMonthValue

Hi could you please help with the percentage. for this calculated months? 

@jayceeb 
Do yu mean something like this?

Variance % =
VAR MaxMonth =
    MAX ( MonthsF[YearMonth] )
VAR MinMonth =
    MIN ( MonthsF[YearMonth] )
VAR MaxMonthValue =
    CALCULATE ( SUM ( Consumptions[Total] ), MonthsF[YearMonth] = MaxMonth )
VAR MinMonthValue =
    CALCULATE ( SUM ( Consumptions[Total] ), MonthsF[YearMonth] = MinMonth )
RETURN
    DIVIDE ( MaxMonthValue - MinMonthValue, MaxMonthValue )

Hi. I tried but all shows zero %.

 

 

jayceeb_0-1685613129426.png

 

@jayceeb 
Change the data type to %. 
However, this gives you the percentage difference between the two selected months if this is what you want.

OMG. Thanks master. 😅🙏

It works. Thank you very much 😭

tamerj1
Super User
Super User

Hi @jayceeb 
I suppose you don't have a date table and the month shown in the visual and the slicer is coming the automatic time intelligence hierarchy?

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors