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.
Hello,
Need some help with DAX please.
I need to count [Number of Active Awards] within a financial period. Then slice this measure by any dimension in the model, not only dates. Here's part of the model. Awards[Award Start Date] = Dates[Cal Date] (active relationship) and Awards[Award End Date] = Dates[Cal Date] (inactive relationship).
THE PROBLEM
If I use ALL(awards), I get a correct count only if I slice/filter by a date but slice by any other column, I get the total in all rows.
Total Active Awards = VAR MaxPeriod = MAX( dates[Cal Date] ) VAR MinPeriod = MIN( dates[Cal Date] ) RETURN CALCULATE( COUNTROWS( awards ), FILTER ( ALL( awards ),
awards[Award Start Date] <= MaxPeriod && awards[Award End Date] >= MinPeriod ) )
If I use ALLEXCEPT(awards, awards[Award Division], projects[Project Status]), I get the correct result as below but then every new dimension I want to slice by I will have to add this column to the ALLEXCEPT. Surely I'm not using the correct DAX function here, please advise?
Total Active Awards = VAR MaxPeriod = MAX( dates[Cal Date] ) VAR MinPeriod = MIN( dates[Cal Date] ) RETURN CALCULATE( COUNTROWS( awards ), FILTER ( ALLEXCEPT( awards, awards[Award Division], projects[project status] ), awards[Award Start Date] <= MaxPeriod && awards[Award End Date] >= MinPeriod ) )
Solved! Go to Solution.
The pattern you use for solving the "events in progress" requires that you don't have any active relationship with the date table.
If you inactivate the second relationship between Awards and Dates and then use this measure it will give you the active awards within the min/max dates.
Total Active Awards = VAR MaxPeriod = MAX( dates[Cal Date] ) VAR MinPeriod = MIN( dates[Cal Date] ) RETURN CALCULATE( COUNTROWS( awards ), FILTER ( awards,
awards[Award Start Date] <= MaxPeriod && awards[Award End Date] >= MinPeriod ) )
There are several good articles written on the subject of "events in progress".
Br,
Magnus
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
101 | |
86 | |
64 |