Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am struggling with writing a DAX for my measure.
Consider following simplified data model:
I have a report filter for the reporting period (from and start dates).
Now based on the selected report filter dates I need to calculate the total Days of Stay within the reporting period.
example., If reporting period is 1/1/2019, to 1/10/2019, I need to calculate a measure as a sum of all Days of Stay that overlap this period. These could be:
I thought it will be easier to split the DAX into above 4 cases and then take a sum of all. Following is what I have written so far for Case 1:
CALCULATE ( SUMX( Stay, DATEDIFF(ReportStartPeriod, ReportEndPeriod, DAY) ), ALL(Stay), FILTER( Stay, Stay[StayStartDate] <= ReportStartPeriod && (Stay[StayEndDate] > ReportEndPeriod ) )
The above works but does not respect any other filters on Stay, e.g. Stay Days by Customer doesn't work. I tried replacing ALL with ALLSELECTED and ALLXCEPT but then I'm not sure how to write the additional Filter condition.
Any help will be appreciated.
Solved! Go to Solution.
Hi @coder_andy ,
In fact, current power bi does not support filter on multiple columns.
You can take a look at the following link about create a bridge table to store all expand the date range records for calculate:
Spread revenue across period based on start and end date, slice and dase this using different dates
Regards,
Xiaoxin Sheng
Hi @coder_andy ,
In fact, current power bi does not support filter on multiple columns.
You can take a look at the following link about create a bridge table to store all expand the date range records for calculate:
Spread revenue across period based on start and end date, slice and dase this using different dates
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |