The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi,
Considering the example:
I would like to compute the sum of timeminutes column for the max value of version column within each idproject column (yellow cells) for each iddate. The result should be the one shown on the right table. What's the best way to do this with dax?
Thank you!
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
timeminutes expected result: =
VAR _maxversiontable =
GROUPBY (
Data,
Data[idproject],
"@maxversion", MAXX ( CURRENTGROUP (), Data[version] )
)
RETURN
IF (
HASONEVALUE ( Data[iddate] ),
CALCULATE (
SUM ( Data[timeminutes] ),
TREATAS ( _maxversiontable, Data[idproject], Data[version] )
)
)
Thank you @Jihwan_Kim !
Would this also work if the max depends on more than one column? For example if I need to consider for the max columns idproject, idcampaign, idemployee, etc?
Hi,
Thank you for your message. It works if the additional columns are included inside the measure.
Hi,
Please check the below picture and the attached pbix file.
timeminutes expected result: =
VAR _maxversiontable =
GROUPBY (
Data,
Data[idproject],
"@maxversion", MAXX ( CURRENTGROUP (), Data[version] )
)
RETURN
IF (
HASONEVALUE ( Data[iddate] ),
CALCULATE (
SUM ( Data[timeminutes] ),
TREATAS ( _maxversiontable, Data[idproject], Data[version] )
)
)
User | Count |
---|---|
14 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
28 | |
19 | |
13 | |
8 | |
5 |