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 guys,
I have a problem with a DAX formula that I hope you can help me with;
I have 3 measures;
Now as you can see in the screenshot above the calculations work fine for each of the individual months, but since the formula of the last measure is [Employees] * [Workhours per month] and not a sum of each of the months the total is wrong.
How could I solve this?
Solved! Go to Solution.
I should probably have mentioned this (sorry) but I'm doind this in an SSAS Tabular model...does this approach still work? I tried to add it but can't get it to calculate properly (never used variables before).
BUT; with the help of a colleage and quite a few iterations (and with your concept of using the date-dimension instead of the fact table for the SUMMARIZE we managed to pull this together that worked:
Available workhours:= SUMX( SUMMARIZE('Date'; Date[Year]; Date[MonthNumber]; "WH"; MAX([Employees_row]) * CALCULATE( SUM([Workhours_row] ); ALL('Projects') ) ); [WH])
you need SUMX to do multiplication first and then sum, and for right granularity you need to summarize first
e.g. something like this
Available workhours = VAR __SummaryPerMonth = ADDCOLUMNS ( SUMMARIZE ( Date, Date[Year]. Date[Month] ), "Emp", [Employees], "WH", [Workhours per month] ) RETURN SUMX ( __SummaryPerMonth, [Emp] * [WH] )
I should probably have mentioned this (sorry) but I'm doind this in an SSAS Tabular model...does this approach still work? I tried to add it but can't get it to calculate properly (never used variables before).
BUT; with the help of a colleage and quite a few iterations (and with your concept of using the date-dimension instead of the fact table for the SUMMARIZE we managed to pull this together that worked:
Available workhours:= SUMX( SUMMARIZE('Date'; Date[Year]; Date[MonthNumber]; "WH"; MAX([Employees_row]) * CALCULATE( SUM([Workhours_row] ); ALL('Projects') ) ); [WH])
depends on which version of SSAS you're using
https://www.sqlbi.com/articles/variables-in-dax/
I think it's only available in SSAS 2016 and onwards, for sure in Azure AS, PowerBI and Excel 2016
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 |
---|---|
113 | |
97 | |
79 | |
73 | |
56 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |