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
vicky2123131
Frequent Visitor

Cannot apply the same measure calculation to find out the previous week value

Hi,

 

I have written a measure to find out the percentage of the products which are missing. Below is the measure which I have written

Percentage of missing product = Coalesce(DIVIDE(
CALCULATE(
DISTINCTCOUNT('Table 1'[ID]),
FILTER('Table 1', Table 1 [Missing_Check] = 1)),
CALCULATE(DISTINCTCOUNT('Table 1'[ID]),0)

 

The above measure will interact with the Weekly snapshot slicer . Below is the sample data for the data slicer which is of type text. If i click any of the weekly snapshot below, the above measure will give the percentage for that particular week.This is working perfectly fine.

vicky2123131_2-1685801415602.png

 

My Question is I want to compare the present week percentage value with the previous week percentage value based on the selection. Considering if I select any of the above weekly snapshot , I should get the respective percentage of that week [In a  card visual ] and in the new measure [ another card visual ]which we are going to write should display the percentage of the previous week based on the that selection. I tried to write but somehow Its not working properly. For example if i select a date 4/24/2023 1st card is showing 20% then the second card should show the value of the previous week which is some percentage say 30% . And in the data we have week number as well, See below screenshot

vicky2123131_1-1685801192150.png

Can anyone help me with the new measure please?

 

 

 

7 REPLIES 7
vicky2123131
Frequent Visitor

Hi @NaveenGandhi Thanks for the reponse. It is not working properly as you can see in the image the previous week's value is not correct. If I change the date slicer to the previous week, the value of the previous week should reflect in the 1st card, but it is showing wrong value. Please find the below screenshot for comparison

 

vicky2123131_0-1685806150008.pngvicky2123131_1-1685806206682.png

I Hope you understand my explanation. the previous week value should be the current week value, if I select the previous week date. In the above example 0.31 in the previous week of 1st screenshot should be the value of the current week in the second screenshot

@vicky2123131

 

Can you explain with respect to the second screenshot(5/15/2023 selected), which weeks data you want in current week's card and which weeks data in previous week card. Explain it using the respective week date for clarity.

 

 

Sure, in the second screenshot 5/15/2023 is the current week as we have selected that date, so the value in the current week card should give the value based on the selection 5/15/2023. But the previous week card should display the value of the previous week from the selected date (i.e) previous week to 5/15/2023 is 5/8/2023 so the second card should give the value for the date 5/8/2023. Hope this explains. Please let me know if you need further details

@vicky2123131 

 

The measure i gave you should do the same as you expected for previous week, can you give me a sample data. I can test out in my file to see the output.

Please find the sample data below

 

Date SlicerWeek Number
4/24/202316
3/27/202312
4/17/202315
4/3/202313
4/10/202314
Today21
5/29/202321
5/8/202318
5/15/202319
5/22/202320
5/1/202317
Today21
5/29/202321
5/29/202321
Today21
4/24/202316
3/27/202312
4/17/202315
4/3/202313
4/10/202314
Today21
Today21
5/29/202321
5/29/202321
5/8/202318
5/15/202319
5/22/202320
5/1/202317
Today21
5/29/202321
Today21
5/29/202321
5/29/202321
Today21
Today21
Today21
5/29/202321
5/29/202321
5/8/202318
5/22/202320
5/15/202319
5/1/202317
Today21
5/29/202321
5/29/202321
Today21
3/27/202312
4/10/202314
4/17/202315
4/3/202313
4/24/202316
5/22/202320
5/15/202319
5/8/202318
Today21
5/22/202320
5/29/202321
5/8/202318
4/10/202314
3/27/202312
5/15/202319
4/24/202316
4/3/202313
4/17/202315
2/13/20236
2/20/20237
3/20/202311
3/13/202310
2/27/20238
3/6/20239

@vicky2123131 

 

It seems to be working as expceted. Check the attached PBIX to see the output.

For context. I have selected 5/08/2022. Below are the data for CW(5/08/2022) & PW(5/01/2022).
CW

NaveenGandhi_0-1685814201139.png

 

PW

NaveenGandhi_1-1685814232492.png


As per above data CW should be 20% and PW should be 66%.

NaveenGandhi_2-1685814277562.png

If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate your kudos!!



NaveenGandhi
Super User
Super User

Hello @vicky2123131 

Use the below measure for previous week. 

Previous Week =
CALCULATE (
[Percentage of missing product],
ALL ( 'Previous Week' ),
'Previous Week'[Week Number]
= SELECTEDVALUE ( 'Previous Week'[Week Number] ) - 1
)

Below is the sample data and result.
NaveenGandhi_0-1685804952090.png

 

NaveenGandhi_1-1685804987684.png
If this post helps, then please consider Accept it as the solution to help the others find it more quickly. Appreciate your kudos!!

 




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.