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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Jay_Mitchel
Frequent Visitor

Variance compared to sum of previous date

Hello all, 

 

Would really appreciate your help.. I have a complex table - but see simplified issue here: 

 

Date Quantity 
15/05/20215
15/05/20214
15/05/20211
15/05/20211
15/05/20211
15/05/20211
15/05/20215
15/05/202155
15/05/20215
16/06/202122
16/06/20211
16/06/20211
16/06/20211
16/06/20211
30/07/202145
30/07/20211
30/07/20211
30/07/20211
30/07/202155
30/07/202150
30/07/20211
30/07/20211

 

I would like to see a % variance (in a matrix) - which would be as below: 

May Jun Jul 
7826155
 -67%496%

 

I would un-select the Month of May - as this month has nothing to compare with.

June is (26-78)/78= -67%

July is (155-26)/26 = +496% 

 

I have researched everywhere & tried countless Dax - nothing seems to work. Thank you in advance.  

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you Ashish. This worked wonderfully!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yalanwu-msft
Community Support
Community Support

Hi, @Jay_Mitchel ;

You could create a column to show month by date; then create a measure as follows:

a)create a column

Mon = FORMAT([Date ],"mmm")

b)create a measure

variance =
VAR _value =
    CALCULATE (
        SUM ( [Quantity] ),
        FILTER ( ALL ( 'Table' ), MONTH ( [Date ] ) = MONTH ( MAX ( [Date ] ) ) - 1 ))
RETURN
    IF (
        ISINSCOPE ( [Month] ),
        SUM ( [Quantity] ),
        FORMAT ( DIVIDE ( SUM ( [Quantity] ) - _value, _value ), "0%" ))

c)change the subtotals label:

vyalanwumsft_1-1625107850960.png

The final output is shown below:

vyalanwumsft_0-1625107809438.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello, 

Still some kinks to work out, but your method appears perfect. 

 

Just one question, what is the empty Month column & why do you reference it in your Dax?

Hi, @Jay_Mitchel ;

Because my dax needs to be based on a column(ISINSCOPE() need), but there is no suitable column in your example, so I created an empty column, if there are other columns, it is fine. Just here for the sake of beauty I created an empty column.
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the help. 🙂 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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