Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Proggesnekka_v2
Regular Visitor

Multiple dummy variables to one column

I have 3 dummy variables, D1-D3. Where I calculate the number of Customers with the measure “No. measure”.

 

Proggesnekka_v2_0-1685966428548.png

 

However, I want to create a variable “Category”, to calculate the No.measure,  like shown below:

 

Proggesnekka_v2_1-1685966428550.png

 

Is there a way to “undo” dummy variables in DAX? The data is stored in datawarehouse, so I can't transform the data in Query.

7 REPLIES 7
mahenkj2
Solution Sage
Solution Sage

Hi @Proggesnekka_v2 

 

One of the way might be in Power query, not sure how is your table and other data but for the sample provided by you, it should work:

 

Sample data used:

D1 D2 D3 No. measure
0 1 0 11492
1 0 0 6699
1 1 0 3272
0 0 1 1324
0 1 1 353
1 0 1 1345
1 1 1 698

 

 

Just past above code in PQ and it should format the table in such way that then you can simply produce the result as below:

mahenkj2_0-1686747170948.png

Hope it helps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlDSUTIEYjBtaGJppBSrEw0XAWEzM0tLuCBMwtjIHKISpgosaWxkAheEqTY2NUYxEqLQxBTFSBA2s7RQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [D1 = _t, D2 = _t, D3 = _t, #"No. measure" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"D1", Int64.Type}, {"D2", Int64.Type}, {"D3", Int64.Type}, {"No. measure", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"No. measure"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Category"}}),
    #"Filtered Rows" = Table.SelectRows(#"Renamed Columns", each ([Value] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Value"})
in
    #"Removed Columns"
lbendlin
Super User
Super User

@lbendlinI can't use the "data-tab". The data is stored in a datawarehouse, and D1-D3 is three different columns. Is it another way around?

No, it's all manual labor from here on.  You have to create a measure that manually collects the data from all three columns.

That's what I feared to do. Can you help me with the code for the measure?

Since you won't be able to provide sample data for your scenario (data warehouse connection)  I won't be able to assist further. I have no access to any such environment.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.