Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Dynamic Percentage calculation based on Selection

Hi,

 

I'm trying to create a measure so that when you open the Power BI report, the values on the report are shows as Current Month (i.e. no date filter has been applied), however when a date filter is applied, then instead of going blank it should show the figures according to that month. 

 

My base measure is:

      Tasks = COUNTROWS(TABLE)

Based on this measure I have created another measure which is:

      Tasks2 = IF(ALL(TABLE),CALCULATE([Tasks],FILTER(Date,[This Month]=1)),[Tasks])

 

So, if no filters are selected then calculate current months total, else calculate selected date/month/year total. 

 

Any help would be useful. 

 

Thanks

2 Replies

  • v-xicai's avatar
    v-xicai
    Community Support

    Hi Anonymous ,

     

    You can create measure Tasks  using DAX below, assuming the date filter is referred to field [DateKey].

     

    Tasks = CALCULATE(COUNTROWS('TABLE'),ALLSELECTED('TABLE'[DateKey]))

     

     

     

     

     

     

     

     

     

     

     

    Best Regards,

    Amy

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Amy,

       

      Thank you for your assistance. However I don't think that is showing what it is that I am after. So I will elaborate on my query to streamline what it is that I'm after.

       

      Currently I have 3 slicers, Date, Month and Year. When nothing is selected in these slicers, the report shows information for over 6 years worth of data. So what I'm trying to do is, before any slicers are selected, the visuals would show results based on the current month, and then when a date/month/year is selected then the visuals would display results based on those slicers. 

       

      As you can see in the image above, the left chart shows current months figures (no slicers selected, done by measure), the right chart shows all figures which would then get filtered by the slicers. 


      So is there a way to combine these two, so that if no slicers have been selected it shows the left chart, but once the slicers get selected it shows results based on the selected value. 

       

      Thanks again.

       

      BA1503