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

% 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
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