Forum Discussion
Reigning_data
7 years agoFrequent Visitor
Create a variable to act as a filter within calculate
Hi All, Apologies if this has been answered before, I have tried to google it but I'm not sure how to pose the question. My issue is this: Say I have several measures that need to do the ...
- 7 years ago
- Does your Period table need to respond to filter context in any way?
If so, then you can't currently do what you've described in a model built in Power BI Desktop. However, you can do this sort of thing Azure Analysis Services, this should eventually be possible in Power BI.
See these articles on DETAILROWS and Calculation Groups:
- If your Period table doesn't need to respond to filter context (e.g. if it's always a fixed date range), then you could use this workaround:
- Create a DAX calculated table called Period using the expression such as in your original post using DATESBETWEEN or some other method.
- Since the Period calculated table won't retain lineage, you can use TREATAS to apply the Period table as a date filter within measures, for example:
Revenue = CALCULATE( SUM ( column1 ), TREATAS ( Period, 'Date'[Date] ) )
Regards,
Owen
- Does your Period table need to respond to filter context in any way?
OwenAuger
Super User
7 years ago
- Does your Period table need to respond to filter context in any way?
If so, then you can't currently do what you've described in a model built in Power BI Desktop. However, you can do this sort of thing Azure Analysis Services, this should eventually be possible in Power BI.
See these articles on DETAILROWS and Calculation Groups:
- If your Period table doesn't need to respond to filter context (e.g. if it's always a fixed date range), then you could use this workaround:
- Create a DAX calculated table called Period using the expression such as in your original post using DATESBETWEEN or some other method.
- Since the Period calculated table won't retain lineage, you can use TREATAS to apply the Period table as a date filter within measures, for example:
Revenue = CALCULATE( SUM ( column1 ), TREATAS ( Period, 'Date'[Date] ) )
Regards,
Owen