Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Measure value changing when using 2 columns in table visual

Hello all. Let me first share a bit of background about the Data Model, Tables, Columns etc. I have a Calendar table in Power BI which has YYYY-MM and CURRENT_FUTURE_MONTH_INDICATOR columns. Since we're in September, for 2021-09 it'll show CURRENT_MTH. For August, it'll show PREVIOUS_MTH. For October, it shows CURRENT_MTH_PLUS_1 and so on. I have created a measure as below :

 

Previous Month Backlog = 
var Result = IF( MIN('Calendar'[CURRENT_FUTURE_MONTH_INDICATOR]) = "CURRENT_MTH", CALCULATE(SUM('Data'[Some_Amt]), 'Calendar'[CURRENT_FUTURE_MONTH_INDICATOR] = "PREVIOUS_MTH" ), BLANK() )
return Result

 

What I am doing here, is that, if it's the current month i.e. Sept (at the time of writing this post), then I wish to compute the SUM(Some_Amt) for previous month. Kinda like, closing amount for previous month becomes opening amount for current month.

NOW, when I drag the CURRENT_FUTURE_MONTH_INDICATOR column from Calendar and my measure into a table visual, I get correct numbers. However, when I drag a third column (YYYY_MM, also from Calendar), the numbers become wrong. Is there any way I can have both columns in the table visual and still get correct numbers ? Any help is appreciated. Thanks in advance.

2 Replies

  • Anonymous , Try like one of the two

     

    Previous Month Backlog =
    var Result = Switch( true() ,
    MIN('Calendar'[CURRENT_FUTURE_MONTH_INDICATOR]) = "CURRENT_MTH", CALCULATE(SUM('Data'[Some_Amt])),
    'Calendar'[CURRENT_FUTURE_MONTH_INDICATOR] = "PREVIOUS_MTH" , BLANK()
    )
    return Result

     

    or

     


    Previous Month Backlog =
    var Result = IF( MIN('Calendar'[CURRENT_FUTURE_MONTH_INDICATOR]) = "CURRENT_MTH", CALCULATE(SUM('Data'[Some_Amt])), BLANK() )
    return Result

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion

    Dataset talks way much more clearly than verbose description.

     

    One thing is for sure, with more columns being added to any viz, filter context changes accordingly.