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 Gurus,
I need help to write a calculatetable function to extract unique values of a column and assign a set of values (Q1,Q2,Q3) to each.
Example:
Table 1:
Column1 |
Oracle |
SAP SAP |
Microsoft |
Microsoft |
Microsoft |
Result Table
Column1 | Quarter |
Oracle | Q1 |
Oracle | Q2 |
Oracle | Q3 |
SAP | Q1 |
SAP | Q2 |
SAP | Q3 |
Microsoft | Q1 |
Microsoft | Q2 |
Microsoft | Q3 |
Hi @Anonymous,
You need a combination of CROSSJOIN and DISTINCT, something like that:
In plain text:
Result =
VAR Quarters = SELECTCOLUMNS ( { "Q1", "Q2", "Q3" }, "Quarter", [Value] )
RETURN
CROSSJOIN ( DISTINCT ( 'Table'[Column1] ), Quarters )
Best Regards,
Alexander
User | Count |
---|---|
69 | |
64 | |
62 | |
55 | |
28 |
User | Count |
---|---|
112 | |
81 | |
65 | |
48 | |
38 |