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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
rkxiii
Frequent Visitor

Percentage Difference based on selected slicer (per week, and per month)

Good day!

 

I would like to ask for your help regarding Percentage Difference Data based on selected slicer (per week and per month).

 

I am using 3 different slicers for my data (Month, Week, and Date) and this is the formula I am using for the Percentage Difference for Date/Day (see formula below)

 

% Diff Day =
Var _Prevdate=CALCULATE(MAX('Input Data'[Date]),FILTER(ALLEXCEPT('Input Data','Input Data'[Model],'Input Data'[Line ]),[Date]<SELECTEDVALUE('Input Data'[Date],'Input Data'[Week])))
Var _PrevYield=CALCULATE([Yield],FILTER(ALLEXCEPT('Input Data','Input Data'[Model],'Input Data'[Line ]),[Date]=_Prevdate))
RETURN
IF(_PrevYield=Blank(),Blank(),[Yield]-_PrevYield)
 

Is it possible to include IF OR Condition for this formula If I only selects for Month or Week Slicer? How to input?

 

For Example: If I selected for the Month Slicer only, it will calculate for the percentage difference from the previous month. Same scenario when I select in the Week Slicer but if I selected for all 3 Slicers, For Example: Month: August, Week: 35, Date: Aug 26, the Percentage Difference will be from the previous day (Aug 25)

rkxiii_0-1724977580128.png

 

Thank you!

5 REPLIES 5
rkxiii
Frequent Visitor

Here's the formula I am using for Percentage Difference per Day

% Diff Day =
Var _Prevdate=CALCULATE(MAX('Input Data'[Date]),FILTER(ALLEXCEPT('Input Data','Input Data'[Model],'Input Data'[Line ]),[Date]<SELECTEDVALUE('Input Data'[Date],'Input Data'[Week])))
Var _PrevYield=CALCULATE([Yield],FILTER(ALLEXCEPT('Input Data','Input Data'[Model],'Input Data'[Line ]),[Date]=_Prevdate))
RETURN
IF(_PrevYield=Blank(),Blank(),[Yield]-_PrevYield)
 
Here's the formula I am using for Percentage Difference per Week
Week Diff =
Var _Prevdate=CALCULATE(MAX('Input Data'[Week]),FILTER(ALLEXCEPT('Input Data','Input Data'[Model],'Input Data'[Line ]),[Week]<SELECTEDVALUE('Input Data'[Week],'Input Data'[Date])))
Var _PrevYield=CALCULATE([Yield],FILTER(ALLEXCEPT('Input Data','Input Data'[Model],'Input Data'[Line ]),[Week]=_Prevdate))
RETURN
IF(_PrevYield=Blank(),Blank(),[Yield]-_PrevYield)
 
I need help on how to combine these formulas with IF OR Statement that when I selected for Week slicer, it will show the % difference from the previous week and same scenario for day slicer. Thank you!
 
Anonymous
Not applicable

Hi, @rkxiii 

 

Can you provide some of the example data? And what you expect the output to be.

 

Best Regards,

Community Support Team _Charlotte

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

Hi, Thank you for the response.

Is it possible for you to combine those 2 formulas above? 

Shravan133's formula gives wrong calculations for week and month percent difference.

 

Here's my expected output as I stated on my post: "If I selected for the Month Slicer only, it will calculate for the percentage difference from the previous month. Same scenario when I select in the Week Slicer but if I selected for all 3 Slicers, For Example: Month: August, Week: 35, Date: Aug 26, the Percentage Difference will be from the previous day (Aug 25)"

 

Thank you very much. 

Shravan133
Super User
Super User

try this: 

% Diff =
VAR SelectedDate = SELECTEDVALUE('Input Data'[Date])
VAR SelectedWeek = SELECTEDVALUE('Input Data'[Week])
VAR SelectedMonth = SELECTEDVALUE('Input Data'[Month])
VAR _PrevDate =
IF(
NOT(ISBLANK(SelectedDate)),
CALCULATE(
MAX('Input Data'[Date]),
FILTER(
ALLEXCEPT('Input Data', 'Input Data'[Model], 'Input Data'[Line]),
'Input Data'[Date] < SelectedDate
)
),
IF(
NOT(ISBLANK(SelectedWeek)),
CALCULATE(
MAX('Input Data'[Date]),
FILTER(
ALLEXCEPT('Input Data', 'Input Data'[Model], 'Input Data'[Line]),
'Input Data'[Week] < SelectedWeek && 'Input Data'[Month] = SelectedMonth
)
),
CALCULATE(
MAX('Input Data'[Date]),
FILTER(
ALLEXCEPT('Input Data', 'Input Data'[Model], 'Input Data'[Line]),
'Input Data'[Month] < SelectedMonth
)
)
)
)

VAR _PrevYield =
CALCULATE(
[Yield],
FILTER(
ALLEXCEPT('Input Data', 'Input Data'[Model], 'Input Data'[Line]),
'Input Data'[Date] = _PrevDate
)
)

RETURN
IF(
ISBLANK(_PrevYield),
BLANK(),
[Yield] - _PrevYield
)

 

test the dax with different combinations of slicers and modify the formula accordingly.

Hi, Thank you for your response. The only problem for this formula is that the accumulated weekly and monthly percentage difference is not accurate. I think it is not based on the previous week/month when I select for week/month slicer

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors