Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi everyone,
I have a table 'ClientInfo' which has (among others) three columns: BeginDate, EndDate, TotalCostsPerDay. Additionally, I have a table called 'DateValues' which has a column called 'Dates'.
I want to add a calculated column 'AggregateCostPerDay' to 'DateValues', where the n-th value is defined as follows:
- Take the 'DateValues'[Dates] value of the n-th row (call this date 'x');
- Get all rows of 'ClientInfo' where the date-range (BeginDate, EndDate) contains this date 'x';
- For these rows, take the sum of the 'TotalCostPerDay' values;
- This sum is the n-th vale of the 'AggregateCostPerDay' column.
I have the following DAX statement, which is not working:
'DateValues'[AggregateCostPerDay] = CALCULATE(SUMX( FILTER(ClientInfo, BeginDate <= 'DateValues'[Dates] && 'DateValues'[Dates] <= EndDate) ))
It's not working because inside the SUMX, 'DateValues'[Dates] is the problem. I would need something like:
'DateValues'[AggregateCostPerDay] = For each 'Date' in 'DateValues'[Dates], CALCULATE(SUMX( FILTER(ClientInfo, BeginDate <= 'Date' && 'Date' <= EndDate) ))
How would I have to do this?
Thanks in advance!
try this as a calculated column in 'DateValues'
AggregateCostPerDay = VAR __Date = 'DateValues'[Dates] VAR __ClientInfo = FILTER ( 'ClientInfo', 'ClientInfo'[BeginDate] <= __Date && 'ClientInfo'[EndDate] >= __Date ) RETURN SUMX ( __ClientInfo, [TotalCostsPerDay] )
if it doesn't work - can you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data? Like this (just copy and paste into the post window).
Column1 | Column2 |
A | 1 |
B | 2.5 |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
12 | |
11 | |
8 | |
7 | |
7 |
User | Count |
---|---|
20 | |
14 | |
11 | |
10 | |
10 |