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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
daniel_19
New Member

Show total value in stacked column chart from measure calculated in DAX

I have a measure in dax that calculates the CPV for Google Analytics channels (d_channels).

I have a table of costs and another of sessions.

My measure calculates the CPV for each channel, but when calculating the total it should be the total invested / total sessions, disregarding the context of channels, because some channels do not have investment value only for sessions. However, when using the stacked column chart, it calculates the sum of each channel grouping, when in fact it was supposed to be calculated as total invested/total sessions. That is, instead of the total over the bars being 1.67 (0.49+1.18), it should return the value of 0.71 calculated by the measure. How can I get it to return 0.71 instead of 1.67? Below is the measurement validated by me and apparently correct.

CPV =
            var final =
                     CALCULATE(
                              SUM(f_COSTS[Value])/[Session]

                                         )

              var total =
                   CALCULATE(
                        SUM(f_COSTS[Value])/[Session],
                               ALL(d_Canais)

                                          )
            

     return
            SWITCH(

               TRUE(),

                ISINSCOPE(d_canais[GROUP2]), final,

                total

                  )

 

WhatsApp Image 2023-03-02 at 11.39.03.jpeg

1 REPLY 1
lbendlin
Super User
Super User

Read about SUMX, SUMMARIZE and table variables.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.