Forum Discussion

kwpbi's avatar
kwpbi
Icon for Helper II rankHelper II
7 years ago
Solved

Interesting challenge... Conditional relative date filter for gauge-type visual? or other solution?

This is a tricky one for me... I am not a Power BI guru or anything (more like a n00b) so maybe this is super easy for some of you... Hopefully?   I am using a gauge-type visual to present sales da...
  • kwpbi's avatar
    kwpbi
    7 years ago

    Chris,

     

    Thanks again for getting me going in the right direction. Once I got familiar with the syntax and how to write out the calculate and sum functions, filters, etc. I was able to make this work for me. Here is the final code, very similar to yours but with a couple tweaks. I'm sure there are other ways to do this, but this is working well now. Thanks.

     

    Daily Sales (Yesterday) =
    VAR _mondayCalc =
        IF (
            WEEKDAY ( TODAY (), 3 ) = 0,
            (CALCULATE ( SUM ( YTD_Invoices[INVOICEAMOUNT] ), YTD_Invoices[INVOICEDATE] = TODAY () - 3 ))+(CALCULATE ( SUM ( YTD_Invoices[INVOICEAMOUNT] ), YTD_Invoices[INVOICEDATE] = TODAY () - 2 ))+(CALCULATE           ( SUM ( YTD_Invoices[INVOICEAMOUNT] ), YTD_Invoices[INVOICEDATE] = TODAY () - 1 ))
        )
    RETURN
        IF (
            WEEKDAY ( TODAY (), 3 ) > 0,
            CALCULATE ( SUM ( YTD_Invoices[INVOICEAMOUNT] ), YTD_Invoices[INVOICEDATE] = TODAY () - 1 ),
            _mondayCalc
        )