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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

% Difference Based On 2 Date Ranges Within The Same Date Column

Hello and thank you in advance for taking the time to consider my question.

 

My goal is to be able to calculate the % difference of the number of Event Id's in a quarter compared to another quarter. I would like the choice of the quarter to be dynamic...for example if I wanted to compare Q1 2021 to Q1 2019, I could select those quarters and the % difference would display. 

 

I created a column to designate the calendar year and quarter but am struggling to visualize the necessary steps to accomplish my goal...any suggestions?

 

sltraffic_2-1624383008456.png

 

 

This is an example of the format of my query. I have entries up to the current day.

sltraffic_1-1624382417390.png

 

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Sorry for the late reply,I think if you use Percent2 ,you could change dax as follows:

Percent2 = DIVIDE(CALCULATE(COUNT('Table'[Event Id]),FILTER(ALL('Table'),[CY & Qtr]=MAX('slicertable'[CY & Qtr])))-COUNT([CY & Qtr]),COUNT([CY & Qtr]))

The final output is shown below:

vyalanwumsft_0-1624929551090.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.

View solution in original post

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Sorry for the late reply,I think if you use Percent2 ,you could change dax as follows:

Percent2 = DIVIDE(CALCULATE(COUNT('Table'[Event Id]),FILTER(ALL('Table'),[CY & Qtr]=MAX('slicertable'[CY & Qtr])))-COUNT([CY & Qtr]),COUNT([CY & Qtr]))

The final output is shown below:

vyalanwumsft_0-1624929551090.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.

v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Based on your description, I have two ideas. One is to use one slicer to select two quarters for calculate the difference percentage, and the other is to use two slicers to select different quarters for the difference percentage.

One slicer: create a measure

Percent =
CALCULATE (
    COUNT ( [Event Id] ),
    FILTER ( 'Table', [CY & Qtr] = MIN ( [CY & Qtr] ) ))
    / CALCULATE (
        COUNT ( [Event Id] ),
        FILTER ( 'Table', [CY & Qtr] = MAX ( [CY & Qtr] ) ))

The final output is shown below:

vyalanwumsft_0-1624589073306.png

Two slicer: create a new slicer table as another slicer.

slicertable = SUMMARIZE('Table',[CY & Qtr])

then create a measure :

Percent2 = COUNT([Event Id])/ CALCULATE(COUNT('Table'[Event Id]),FILTER(ALL('Table'),[CY & Qtr]=MAX('slicertable'[CY & Qtr])))

The final output is shown below:

vyalanwumsft_1-1624589223703.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.

Anonymous
Not applicable

This is GREAT!! It's doing exactly what I was looking for. Thank you so much! I elected to go with the Percent2 option to allow a percent increase or decrease to display.

 

After reviewing the result in more detail, I thought it might be better to display the % Increase instead. Is there anyway to revise the percent2 equation to achieve this result.

To calculate the percentage increase:

First: work out the difference (increase) between the two numbers you are comparing.

Increase = New Number - Original Number

Then:  divide the increase by the original number and multiply the answer by 100.

% increase = Increase ÷ Original Number × 100.

If your answer is a negative number, then this is a percentage decrease.

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.