How to sum a data table in Power BI

0 votes

I have a visualization in my report made by data table that pulls entirely from a single table.  

The contents of this table contains several calculated columns which are written in DAX.  One among these columns takes the sum of the previous 3 columns and then returns a value based on a SWITCH statement.  

I am trying to attempt 'SUM'  of the values in this SWITCH statement column in order  to get the total at the bottom. Earlier used the following measure to calculate the SUM

Cyclestar Pay Real Values =
IF(COUNTROWS(VALUES(ClassSchedule[ID of Class]))=1,
[CycleStar Pay],
SUMX(VALUES(ClassSchedule[ID of Class]), [CycleStar Pay]))

I am not able to figure out how to sum the values in this column correctly.

May 16, 2019 in Power BI by Phalguni
• 1,020 points

edited May 17, 2019 by Omkar 7,525 views

1 answer to this question.

0 votes

It's a good practice if you avoid the measures that are designed keeping specific visualization in mind. 

Let us consider an example based on the data provided above.

1. The years are identifiers for the rows in the table

2. If any other column or row is added like month then the behavior of the measure will be different

The part of your formula for the calculation the total measure would work  well on the detail rows when iterating over VALUES(Table[Year] instead of Table itself:

MyMeasure3 = SUMX(FILTER(VALUES(Table[Year]),[Amount]>1000),[Amount]-1000)

However, VALUES(Table[Year]) would contain only one row while the filtered table is empty when [Amount]<=1000. 

This means that rows for years with [Amount] lower than 1000 should have a blank value. In case you want to have 0 instead of blank, you can just add 0 to the result:

MyMeasure3 = SUMX(FILTER(VALUES(Table[Year]),[Amount]>1000),[Amount]-1000) + 0

Hope this helps!!

If you are interested in learning Power BI, check out Power BI Curriculum now!

answered May 17, 2019 by Avantika
• 1,520 points

edited May 17, 2019 by Omkar

Related Questions In Power BI

+1 vote
1 answer

Is there a way to convert JSON data to readable table in power bi

Follow these steps step 1 - Click on ...READ MORE

answered Sep 24, 2018 in Power BI by Hannah
• 18,520 points
13,994 views
0 votes
1 answer

How to create a relative data slicer in Power BI?

Hi, With the relative date slicer or filter, you ...READ MORE

answered Jan 31, 2020 in Power BI by Shivani
1,964 views
0 votes
1 answer

How to create a new slicer to filter data by district manager in Power BI?

Follow the steps Open power bi  desktop nd ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale
952 views
0 votes
1 answer

How to troubleshoot a refresh on data set in power bi service

Hello, @vnk, You may see an error when ...READ MORE

answered Sep 14, 2020 in Power BI by Gitika
• 65,770 points
1,040 views
0 votes
1 answer

Install Power BI Desktop

It’s a pretty simple process. All you ...READ MORE

answered Oct 9, 2018 in Power BI by Kalgi
• 52,350 points
1,022 views
0 votes
1 answer

Few tips before I start creating Power BI dashboard

It’s always advisable to begin with the data ...READ MORE

answered Oct 9, 2018 in Power BI by Kalgi
• 52,350 points
886 views
0 votes
1 answer

How do I format the KPI in Power BI

format the KPI by selecting the paint ...READ MORE

answered Oct 9, 2018 in Power BI by Kalgi
• 52,350 points
1,233 views
+1 vote
1 answer
0 votes
1 answer

How to Export data in Power BI online version?

Hi, You can export your data from any ...READ MORE

answered May 27, 2019 in Power BI by Avantika
• 1,520 points
1,104 views
0 votes
1 answer

How do you create a link visual in Power BI?

You can easily create a link between ...READ MORE

answered Mar 9, 2019 in Power BI by Avantika
• 1,520 points

edited Mar 9, 2019 by Avantika 5,145 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP