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

Sum the values of a particular column based on multiple slicer selections

Hi - I am trying to figure out how to calculate PQ column for it to give the sum of all selected quarters in the slicer. Right now it's giving values only for 1 quarter as I have used SELECTEDVALUE. I have tried using functions such as countx, ALLSELECTED, SUM but nothing seems to work

J0676s_0-1709750776285.png

 

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @J0676s ,

Please try this measure:

Orders PQ # = CALCULATE([PQ SUM],DATEADD('Calendar'[Date],-1,QUARTER))

Output:

vcgaomsft_0-1709790759186.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

6 REPLIES 6
v-cgao-msft
Community Support
Community Support

Hi @J0676s ,

Please try this measure:

Orders PQ # = CALCULATE([PQ SUM],DATEADD('Calendar'[Date],-1,QUARTER))

Output:

vcgaomsft_0-1709790759186.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

@v-cgao-msftIt's working, thank you so much! Appreciate your help

Doesn't look like that'd work if you select consecutive quarters.

j_ocean
Helper V
Helper V

I think the selectedvalue would have to be values() to return an array of multiple values just to get the multiple selections in the DAX measure. From there you would need to define a range for the prior period, something like

 

prevperiodend = min(values()) - 1 
prevperiodbegin = prevperiodend - (max(values()) - min(values())

 

Of course with only 4 qtrs / year and allowing multiple selections the odds you'll cross over a year are pretty good so doing it based on quarter might fail unless it's counting squentially across years.

Thank you for your response. 

 

I am a beginner and still learning. To sum up, are you suggesting to first create meausres for Prevperiod begin and Prevperiodend and then using that create a PQ measure?

Measures or variables within the measure. DAX isn't my strong suit but just coding logic you have to define the range the user seelcted and then compute an equivalent prior period before you can hope to use them as filters.

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.