cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Osama14
Frequent Visitor

Getting the total value of a created Measure

I am still developing in power Bi, I am having an issue in getting the total value of a calculated measure, the measure is calculating daily consumption readings and i want to get the total for the selected period. 

This is the measure formula: 

Meter 1 Consumption =
VAR ConsumptionToday =
CALCULATE(SUM(ConsumptionDaily[QC Meter 1]))
VAR ConsumptionPriorDay =
CALCULATE(SUM(ConsumptionDaily[QC Meter 1]), PREVIOUSDAY('ConsumptionDaily'[Date]))
VAR DIFF =
ConsumptionToday - ConsumptionPriorDay
RETURN
IF(ISBLANK(ConsumptionPriorDay),BLANK(),IF(DIFF<0,DIFF+9999999,DIFF))

How to get the sum of Meter 1 Consumption, i have tried to use sumx and seen some solutions using HAS1Filter 

Sum of Meter 1 = CALCULATE(SUMX(ConsumptionDaily,[QC Meter 1 Consumption]))

But it is showing blank, 

If you can help please 

 

1 REPLY 1
Schmidtmayer
Helper I
Helper I

You should use the effect of a telescopic sum here.
Instead of summing over all of the daily consumptions, just calculate the difference between first consumption and last consumption within the time, using your logic:

Meter 1 Consumption =
VAR MaxDate = MAXX(Datecolumn)
VAR MinDate = MINX(Datecolumn)
VAR ConsumptionEnd =
CALCULATE(SUM(ConsumptionDaily[QC Meter 1]), date = MaxDate)
VAR ConsumptionStart =
CALCULATE(SUM(ConsumptionDaily[QC Meter 1]), Datecolumn = MinDate)
VAR DIFF =
ConsumptionEnd - ConsumptionStart
RETURN
IF(ISBLANK(ConsumptionStart),BLANK(),IF(DIFF<0,DIFF+9999999,DIFF))

Might need to substract one day from MinDate.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors