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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
CALCULATEpizza
Frequent Visitor

Create Measure - Period On Period % Diff, Based On User's Input In Built-In Relative Date Slicer For

Hi everyone!

 

Would appreciate any help on the following requirements:

 

I'd like to create a measure for:

- Period On Period % Diff

- Based On User's Input In Built-In Relative Date Slicer

- For Matrix Visual With Date Dimension In Columns (Year, Month, Week)

 

The month column in matrix should also show month names (Jan, Feb, Mar, etc...)

 

Here's the pbix file

https://wetransfer.com/downloads/c4520acc0588798246d10c01d429de6420220330165102/76b28ehttps://wetran...

 

The dataset is shown in the picture below. 

 

Screenshot 2022-03-27 183010.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The expected results are below:

(Disclaimer - I had to create 2 separate measures in order to show the expected results. Whereas what I'd like is to have a single measure that is able to display the output show by these 2 measures. Extending further, it should also show the correct output when, for example, "last 3 days" is selected in slicer, but matrix column is on weekly level. Or "last 3 weeks" selected in slicer, but matrix column is on monthly level.)

 

When selecting "last 2 months" on slicer, and matrix column is on monthly level:2 Months.png

 

When selecting "last 3 months" on slicer, and matrix column is on monthly level:

3 Months.png

 

When selecting "last 2 weeks" on slicer, and matrix column is on weekly level:

2 Weeks.png

 

 

 When selecting "last 3 weeks" on slicer, and matrix column is on weekly level:

3 Weeks.png

 

 

1 ACCEPTED SOLUTION

Hi @CALCULATEpizza ,

 

Believe that the main issue you have here is the fact that you cannot know how the relative slicer selection is made, if it's on weeks, month or days.

 

What you can do keeping the two measures you have is to create a measure that gets the context of the matrix, and returns the correct measure:

 

Switch bewteen = if(ISINSCOPE('Date Dimension'[Week]), [WEEK ON WEEK % DIFFERENCE], [MONTH ON MONTH % DIFFERENCE])

 

Has you can see when you drill up or down the calculations changes:

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @CALCULATEpizza ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR _sum =
    CALCULATE (
        SUM ( 'Sales Data'[QTY Sold] ),
        FILTER (
            ALL ( 'Date Dimension' ),
            'Date Dimension'[Week] = SELECTEDVALUE ( 'Date Dimension'[Week] )
        )
    )
RETURN
    DIVIDE ( SUM ( 'Sales Data'[QTY Sold] ), _sum )

vpollymsft_0-1648604256779.png

If I have misunderstood your meaning, please provide your desired output with a screenshot.

How to Get Your Question Answered Quickly 

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous, 

 

Thanks so much for your response, unfortunate the measure doesn't provide the output I'm looking for. I've updated my original post with the expected results.

 

I have also reuploaded the pbix file. In this update:

- added 2 measures to demonstrate what the output should be

Hi @CALCULATEpizza ,

 

Believe that the main issue you have here is the fact that you cannot know how the relative slicer selection is made, if it's on weeks, month or days.

 

What you can do keeping the two measures you have is to create a measure that gets the context of the matrix, and returns the correct measure:

 

Switch bewteen = if(ISINSCOPE('Date Dimension'[Week]), [WEEK ON WEEK % DIFFERENCE], [MONTH ON MONTH % DIFFERENCE])

 

Has you can see when you drill up or down the calculations changes:

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix Thanks so much! This solves exactly what I'm trying to accomplish. Appreciate your time looking into this.

Hi @CALCULATEpizza ,

 

Add and index colum for the week:

INT( ROUNDDOWN( ( DATEDIFF( [Date], TODAY(), DAY) * -1 + -1 * IF( WEEKDAY( TODAY() ) + 1 <= 6, WEEKDAY( TODAY() ) + 1, WEEKDAY( TODAY() ) + 1 - 7 )) / 7, 0 ) )

 

 

Then try the following measure:

Measure = var WeekSelection = 
 MAX('Date Dimension'[weekindex]) - 1 

var _sum = CALCULATE(SUM('Sales Data'[QTY Sold]), FILTER(ALL('Date Dimension'),'Date Dimension'[weekindex] = WeekSelection))
return
DIVIDE(SUM('Sales Data'[QTY Sold]), _sum)

MFelix_0-1648639722046.png

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @CALCULATEpizza 

 

You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix thanks so much for the tip!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.