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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
itsmeanuj
Helper IV
Helper IV

Cumulative total while switching values

Hi Guys,

 

My Data looks like this and I need to show it in a matrix visual with a cumulative sum of values. Please note that there is a slicer filter at the top that switches the column values between Month_num and Month.

 

Input

CountryValueMonth_numMonth
US10011/1/2022
US12022/1/2022
US14033/1/2022
US11044/1/2022
US14555/1/2022
US18066/1/2022
US17077/1/2022
Germany14014/1/2022
Germany15025/1/2022
Germany16036/1/2022
Germany17047/1/2022
Germany18058/1/2022
Germany13069/1/2022
Germany140710/1/2022

 

Output 1 - Wheb Slicer value is selected as Month

Month1/1/20222/1/20223/1/20224/1/20225/1/20226/1/20227/1/20228/1/20229/1/202210/1/2022
US100220360470615795965   
Germany   1402904506208009301070

 

 

Output 2 - When the slicer value is selected as Month_num

Month_num1234567
US100220360470615795965
Germany1402904506208009301070

 

Can someone please help me to achieve this?

 

Thanks,
Anuj

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

4 REPLIES 4
Ahmedx
Super User
Super User

pls try this

Screenshot_5.png

Ritaf1983
Super User
Super User

Hi @itsmeanuj 
If I understood you correctly and you are working with the field parameters you can apple the following steps :
1. Add to the field parameter column of the slicer's selections ( you will need it at the dax that will switch the formula according to your selection)

Ritaf1983_0-1702881512903.png

2. Use this formula for the calculation of the running total :

runming total =
if(SELECTEDVALUE(Parameter[Month type])="month_num",
CALCULATE(

            SUM('Table'[Value]),

            FILTER( ALLSELECTED('Table'[Month_num]),

          'Table'[Month_num]<= MAX(('Table'[Month_num]) )

            )),
            CALCULATE(

            SUM('Table'[Value]),

            FILTER( ALLSELECTED('Table'[Month]),

          'Table'[Month]<= MAX(('Table'[Month]) )

            ))

)
3. On the slicer, use the new column from step 1
Ritaf1983_1-1702881685090.png

4. Create the matrix (parameter should be on columns)

Ritaf1983_2-1702881734031.png

Result:

Ritaf1983_3-1702881789368.pngRitaf1983_4-1702881811010.png

PBIX is attached

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

@Ritaf1983 - Thanks for your response on this. I realized that in the sample data, you have changed the dates of Germany. US data is from Jan-22 to July 22. Germany is from April 22 to Oct-22. In the actual data, there are a lot more countries with different starting dates. will this solution still work in that scenario?

Hi @itsmeanuj 
This logic will work for any date format according to your needs, everything is dynamic in my formulas.
I changed your format just because my settings are dd/mm/yyyy , and I didn't want to reset them just for the sample solution 🙂

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.