Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Make calculation react to date slicer

I have this expression, I want it to react to a slicer linked to Meetings'[Date]

Visited_Regions=DIVIDE( COUNTROWS(  INTERSECT( VALUES('Meetings'[Region]),  VALUES('Priorities'[Region]) ) ),  COUNTROWS(DISTINCT('Clinic priority'[Region])))

 

the result is a % - priorities do not change so it doesn't have a date column

 

could you help me?

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Anonymous 

     

    Make sure the slicer is set to filter the table by . For guidance on setting up slicers, including date slicers, you can refer to the official documentation here:

     

    Create a numeric or date range slicer in Power BI - Power BI | Microsoft Learn

     

    Make sure that there is a relationship between the table and any other tables that need to be indirectly filtered by date selection. If the and tables need to react indirectly to the date slicer, consider how they relate to the tables in the model.


    The formula used by the DAX formula should respect the filter context imposed by the slicer. However, make sure that there are no context conversion issues.


    If the direct method doesn't work because of the missing date column in , consider creating a calculated table that aggregates priorities by date, or using measures to dynamically calculate the total priority as the denominator in the DIVIDE function, and then essentially respect the context of the slicer

     

    How to Get Your Question Answered Quickly 

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

    Best Regards

    Yongkang Hua

    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

      Thank you. I went a different way to reach my objective hence I didn't try your solution.

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello. I am in a similar position again. I tried your approach and still couldn't manage. Here the new case: 

      Totalattendedevents = CALCULATE( DISTINCTCOUNT('Eventregistration'[eventID]),   FILTER(  'Eventregistration',  'Eventregistration'[Attended] >= 1),  USERELATIONSHIP('Date'[Date], 'Eventregistration'[Date]))
      I have a Many to one single relationship built between the 'Eventregistration'[date] and the 'Date'[Date], both have the date format as "short date". When the USERELATIONSHIP is not in the calculation, I see the total amount no matter the slicer (Date'[Date]), when I have it active, if I use the slicer, then I have 0. I have another table "meetings" with the date reacting correctly to the (Date'[Date]). So the final table needs to show me both the total meetings and the todtal events in the same time period. What am i doing wrong?  thank you