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 August 31st. Request your voucher.
Hello,
Could someone help with the below please?
In a calculated column, I need to return the max string for a filtered set of values for differnet records.
If I was doing this in SQL I would use something like:
max(case when Table2.[Task Code] in ('TASK1A1','TASK1A2,'TASK2A1','TASK2A2') then Table2.[Task Code] end) over (partition by Table1.[Ref No])
This is what my dataset looks like - I do not want to return information on TASK3A1,TASK4A1.
I tried using MAXA to return the max string but as documented it only works with integers/dates etc. This is what I've tried so far:
evaluate sumarize ( 'Table1'[Ref No], "Max Relevant Task Stage", calculate(maxa('Table2'[Task Code]), filter('Table2', 'Table2'[Task Code] ="TASK1A1" || 'Table2'[Task Code] ="TASK1A2" ||'Table2'[Task Code] ="TASK2A1" || 'Table2'[Task Code] ="TASK2A2" ) ) )
But it just returns '0' for the Desired Result instead of one of the four required task codes listed in the Dax.
Could anyone show me an alternative please?
Thanks,
pbix
Hi @Anonymous,
Assuming that you have table like below.
And your desired output is the calculated column which return the max string value.
Please try the formula below.
Column = VAR temp = SUMMARIZE ( FILTER ( 'Table1', 'Table1'[Task Code] IN { "TASK1A1", "TASK1A2", "TASK2A1", "TASK2A2" } ), Table1[Ref No], "Max Relevant Task Stage", CALCULATE ( MAX ( Table1[Task Code] ), VALUES ( Table1[Ref No] ) ) ) RETURN MAXX ( FILTER ( temp, [Ref No] = EARLIER ( Table3[Ref No] ) ), [Max Relevant Task Stage] )
More details, you could refer to the attachment.
Best Regards,
Cherry