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

Sum with 2 filters based on 1 selected date in the slicer

Hi Experts

 

I have a table of forecast with 2 columns for months, DemandMonth and SnapMonth (see below, all in date format), and the DemandMonth is linked to MonthDate in the time master (see below). The objective is to sum Value in forecast based on the selected Monthdate plus the related SnapMonth.

The 1st phase is simple, just sum the value of the month selected. I did a measure below which works.

Measure1 = CALCULATE(SUM('Forecast'[Value]),FILTER('Forecast',[DemandMonth]=SELECTEDVALUE('Time'[MonthDate])&&'Forecast'[SnapMonth]=SELECTEDVALUE('Time'[SnapMonth])))
However, when I try to sum for the previous month simultanesouly with measure below it returns nothing.
Measure2 = CALCULATE(SUM('Forecast'[Value]),FILTER('Forecast',[DemandMonth]=SELECTEDVALUE('Time'[-1MonthDate])&&'Forecast'[SnapMonth]=SELECTEDVALUE('Time'[-1SnapMonth])))
Look forward to your comments. Thanks
 
Forecast

yamacha_0-1611048927989.png

Time Table

yamacha_1-1611049149589.png

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , if they connected the sleected value is no a good idea , If the time table is disconnected

Try like 

Measure1 = CALCULATE(SUM('Forecast'[Value]),FILTER('Forecast',[DemandMonth] in values('Time'[MonthDate])&&'Forecast'[SnapMonth]=SELECTEDVALUE('Time'[SnapMonth])))

 

Measure2 = CALCULATE(SUM('Forecast'[Value]),FILTER('Forecast',[DemandMonth] In values('Time'[-1MonthDate]) && 'Forecast'[SnapMonth] in values('Time'[-1SnapMonth])))

 

Also explore userelationship, if you want to need one table at a time

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in-power-bi

https://www.youtube.com/watch?v=e6Y-l_JtCq4

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , if they connected the sleected value is no a good idea , If the time table is disconnected

Try like 

Measure1 = CALCULATE(SUM('Forecast'[Value]),FILTER('Forecast',[DemandMonth] in values('Time'[MonthDate])&&'Forecast'[SnapMonth]=SELECTEDVALUE('Time'[SnapMonth])))

 

Measure2 = CALCULATE(SUM('Forecast'[Value]),FILTER('Forecast',[DemandMonth] In values('Time'[-1MonthDate]) && 'Forecast'[SnapMonth] in values('Time'[-1SnapMonth])))

 

Also explore userelationship, if you want to need one table at a time

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in-power-bi

https://www.youtube.com/watch?v=e6Y-l_JtCq4

Anonymous
Not applicable

Thanks@amitchandak, I tried to disconnect the time table with the forecast, and found it works!!!!

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.