cancel
Showing results 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

Frequent Visitor

## Year on Year Difference

Hi @all,
Is it possible to create a measure to find variance in PowerBI like below?

6 REPLIES 6
Frequent Visitor

Hi Ashish,
Thanks for the response. Yes, the row labels are coming from the slicer and there would always be 2 dates in the row labels.

Super User

Hi,

Assuming you have a Calendar Table and the dates in the row labels are from th Calendar Table, try this DAX pattern

=calculate([Total],datesbetween(Calendar[date],MAXX(allselected(Calendar),calendar[date]),MAXX(allselected(Calendar),calendar[date]))-calculate([Total],datesbetween(Calendar[date],minx(allselected(Calendar),calendar[date]),minx(allselected(Calendar),calendar[date]))

Regards,
Ashish Mathur
http://www.ashishmathur.com
Frequent Visitor

Hi Ashish,
I really appreciate your solution. Unfortunately, I'm experiencing an error: "A function 'DATESBETWEEN' has been used in a True/False expression that is used as a table filter expression. This is not allowed"

`CALCULATE ( [Net Debt], DATESBETWEEN ( DimValdate[ValDate], MAXX ( ALLSELECTED ( DimValdate ), DimValdate[ValDate] ), MAXX ( ALLSELECTED ( DimValdate ), DimValdate[ValDate] ) ) - CALCULATE ( [Net Debt], DATESBETWEEN ( DimValdate[ValDate], MINX ( ALLSELECTED ( DimValdate ), DimValdate[ValDate] ), MINX ( ALLSELECTED ( DimValdate ), DimValdate[ValDate] ) ) ) )`
Super User

You are welcome.  There should be another closing bracket before the - sign and remove one closing bracket from he end.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Frequent Visitor

Hi Ashish,
The modified formula did work but unfortunately didn't achieve what was actually expected.
Rows: ValDate (i.e Dec & June)
Columns: Fiscal Year (FY23, FY24,....)
Value: Net Debt(measure) , Net Debt Variance

Super User

Hi,

What would the result be if there were more than 2 dates in the row labels?  Also, are the row labels coming from a slicer selection?

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### 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.

#### Power BI Monthly Update - June 2024

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

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

#### New forum boards available in Real-Time Intelligence.

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

Top Solution Authors
Top Kudoed Authors