Forum Discussion

user01's avatar
user01
Resolver I
1 year ago
Solved

Dynamic starting date based on filter for bar chart

I get data via DirectQuery and we publish our report our Power BI app, but I provided some dummy data below. We have Product P sales data starting May 2024. We have Product D and Product E sales data...
  • user01's avatar
    1 year ago

    I re-did my approach. I made one measure to indicate whether or not E or D is selected by counting the E/D rows by using SUMX. Then I wrote another measure based on the first one.

    EDRows = SUMX(ALLSELECTED('Table'), IF('Table'[PRODUCT] in {"E", "D"}, 1, 0))
    
    sum_salesx = 
    var _ed = [EDRows2] > 0
    var _eddate = IF(_ed, "202409", "202405")
    return SUMX('Table',IF('Table'[YRMO] >= _eddate, 'Table'[SALES] + 0, BLANK()))

     

    I put sum_salesx as the Y-axis in the bar chart and it seems to work fine. And in the X-axis, "Show items with no data" is not selected.