Power BI Exchange

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
Expand all | Collapse all

Getting the total value of a created Measure

  • 1.  Getting the total value of a created Measure

    Posted Sep 09, 2021 03:13 AM
    I am still developing and learning power Bi, I am having an issue in getting the total value of a calculated measure, the measure is calculating daily consumption readings from an accumulated values, and i want to get the total for the selected period.

    The Table name is ConsumptionDaily and column is QC Meter 1 

    This is the formula measure: 

    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 can i 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 when adding into a visual, 

    If you can help please




    ------------------------------
    Osama Ashraf
    Jr Data specialist
    ------------------------------


  • 2.  RE: Getting the total value of a created Measure

    Posted Sep 11, 2021 10:33 AM
    Hi @Osama Ashraf,

    Knowing nothing about your Model makes this a bit of a guessing game, but since you have a date field ​and are using a date in your visual - you must have a (proper) Date table, right? Try something like this.

    SUMX(
        ADDCOLUMNS(
            VALUES( Dates[Date] ),
            "Value", [Meter 1 Consumption]
        ),
        [Value]
    )

    Review this video if you run into any issues.
    Calculate totals by summing visible values in DAX

    I hope this is helpful

    ------------------------------
    Melissa de Korte
    ------------------------------



  • 3.  RE: Getting the total value of a created Measure

    Posted Sep 13, 2021 12:48 PM
    Hi @Melissa,

    Thank you for your reply and suggested solution

    I have the formula as a calculated column from M query and then created a measure ​for total of each meter which is much easier.

    Thanks

    ------------------------------
    Osama Ashraf
    Jr Data specialist
    ------------------------------