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

DAX To Calculate the Difference between two months of a Measure

I have a number of similiar measures, e.g.

 

Risk Count = CALCULATE(
                COUNT('Flags Data'[Risk]),
                'Flags Data'[Risk] = "0"
)

I have used these in a matrix against some name and and showing Months as a Column Value, there are 2 months.

 

I wish to show the difference between the two months but am unsure how.

 

I have tried the below to get the previous month count, with the intention of subtracting the two, but this just show as a blank, and also it shows up  in the matrix for both months, when I just want one difference column.

 

Previous Month Risk Count = CALCULATE( [Risk Count],
                            PREVIOUSMONTH(DateTable[Date]))

Any advice appreciated!

 

 

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@Anonymous seems like you have date dimension in your model which is good. From which table you are showing column in your matrix? Are you showing month from DateTable?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

@Anonymous you can be smart with your Risk Difference measure to return blank value in case of May and in that case you will not see value for May, although the header will be there whcih you can minimize and turn off auto width.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Thx!

 

That was the issue! I was using the Date field in my Fact Table!

Anonymous
Not applicable

However, this still isn't quite what I want.

 

I created a measure  for the difference, using the measure stated above.

 

Risk Count Diff = [Risk Count] - [Previous Month Risk Count]

When I bring that into my table this gives a column for both my selected months, but I want to only show the later month.

 

So Matrix is show these Columns

May                                       June   
Risk Count     Risk Count Difference      Risk Count     Risk Count Difference

But I want to see

 

May            June   
Risk Count     Risk Count     Risk Count Difference

Any ideas?

@Anonymous I dont htink you can do that but instead, you drop all 3 measures on value

 

- Risk Count

- Previous Month Risk Count

- Risk Difference

 

and filter on most recent month.

 

This way you will only see June month on the header with 3 measures. Previous month implied it is May, Although if you want both the months on header, you cannot do it with matrix. Matrix is going to show all the values for each column (month)



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thats a shame, I can't do that as I have other measures in the table that I need to see for May.

@Anonymous you can be smart with your Risk Difference measure to return blank value in case of May and in that case you will not see value for May, although the header will be there whcih you can minimize and turn off auto width.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

There is no elegant soution, just have to use some tricks.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous seems like you have date dimension in your model which is good. From which table you are showing column in your matrix? Are you showing month from DateTable?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.

Top Solution Authors