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 All,
I'm trying to write a DAX that will return the latest value for each company, based on a specific reporting date.
Each company has multiple transactions with different transaction dates. Some of them have a transaction date that is equal to the reporting date, but some of them have the latest transaction date earlier. I want to get all the latest values and the correct total in the table. I can return all the latest values, but the total is not correct.
Here is the dataset:
Reporting date is 31/12/2021, and the expected result is 6.500.951.
Can anyone assist me with this, please?
Thanks.
Solved! Go to Solution.
I've figured it out.
First I have created this measure:
Transaction Value =
VAR maxasAtDate =
MAX ( 'As At Date'[Date] )
VAR maxrepDt =
MAX ( 'Date'[Date] )
VAR maxdt =
MIN ( maxasAtDate, maxrepDt )
VAR maxTrxDate =
CALCULATE ( MAX ( 'Test File'[Transaction Date] ), 'Date'[Date] <= maxdt )
RETURN
CALCULATE (
SUM ( 'Test File'[Value] ),
ALL ( 'Date' ),
'Date'[Date] >= maxTrxDate,
'Date'[Date] <= maxdt
)
And then another one to get the total amount correctly displayed in a table:
Transaction Value (Total) =
SUMX ( SUMMARIZE ( 'Test File', Dim_Company[Company] ), [Transaction Value] )
I've figured it out.
First I have created this measure:
Transaction Value =
VAR maxasAtDate =
MAX ( 'As At Date'[Date] )
VAR maxrepDt =
MAX ( 'Date'[Date] )
VAR maxdt =
MIN ( maxasAtDate, maxrepDt )
VAR maxTrxDate =
CALCULATE ( MAX ( 'Test File'[Transaction Date] ), 'Date'[Date] <= maxdt )
RETURN
CALCULATE (
SUM ( 'Test File'[Value] ),
ALL ( 'Date' ),
'Date'[Date] >= maxTrxDate,
'Date'[Date] <= maxdt
)
And then another one to get the total amount correctly displayed in a table:
Transaction Value (Total) =
SUMX ( SUMMARIZE ( 'Test File', Dim_Company[Company] ), [Transaction Value] )
@rile14 Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
75 | |
63 | |
51 | |
48 |
User | Count |
---|---|
211 | |
86 | |
64 | |
59 | |
56 |