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.
Hi everyone,
I would like to use a dax formula to count the number of rows under a specific date restriction, by using one date slicer.
The goal is to count the available objects, by only including the rows where:
Selected date < Arrival date
Selected date >= Departure Date
Selected date < blocked from
Selected date >= blocked until
Selected date < Not available from
Considering the model below, I tried the following dax formula:
There is an active relationship between Date and Arrival. The other relationships are inactive. However, the Dax formula does not work. Does anyone have an alternative for this?
Kind regards,
Jaap
@jvelling Have you tried using ALL(Date Key Tabel) instead of the ALLSELECTED(...) (you might also need to change the MAX expressions and use SELECTEDVALUE) ?
Proud to be a Super User!
Paul on Linkedin.
Hi @PaulDBrown ,
Thanks for your response. Unfortunately this doesn't work either. In both cases I get an error saying the model is ambigiuous.
you could try using CROSSFILTER.
Assuming the active relationship between the date table and the fact table is between the column Date table [Date] and the column Fact table [Arrival] (adjust accordingly), and your present measure (as you have above) is [AVAILABILITY]
If that doesn't work you need a duplicate of your date table (with inactive relationships to your fact table) to use as a slicer. You can then use USERELATIONSHIP to calculate the values and SELECTEDVALUE as the reference in the FILTER expressions
Proud to be a Super User!
Paul on Linkedin.
Hi @PaulDBrown ,
Thanks again for your quick response. I have tried both of your suggestions, but in both cases the ambiguity remains. To verify if I am following you correctly in your second suggestion:
1. I created the following model
2. I have put kalender2 date in the slicer
3. I have changed the measure to:
Is this following along your suggestion?
Thanks a lot so far!
I think the issue is with the FILTER expressions. You are removing the filter from the fact table with the ALL expression when you should be removing the filters from the date table FILTER(ALL(Date table), .....
(Sorry, I should have seen that before, but the name of the table DATEKEY made me think of a Date table, when in fact your date table is "Kalender")
try that and see if it solves it
Proud to be a Super User!
Paul on Linkedin.
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 |
---|---|
110 | |
97 | |
78 | |
63 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |