Forum Discussion

justinMcC's avatar
justinMcC
Frequent Visitor
8 years ago
Solved

Turning a measure into a column

Hi,   I have a calculated measure on a table in PowerBi desktop report to categorise holdings as 'dairy' or 'beef'    However I need to turn the data in table into a chart and I cannot use the me...
  • v-jiascu-msft's avatar
    8 years ago

    Hi justinMcC,

     

    Here is two solutions based on your data and WolfBiber's idea.

    1. Calculated table.

    CalculatedTableM1 = 
    	ADDCOLUMNS(
    		SUMMARIZE('Table1', 
    				Table1[HoldingID], 
    				"SumPercent_dairy", sum(Table1[percent_dairy])),
    				"Category", if([SumPercent_dairy]>=80, "DAIRY","BEEF"))

    2. Measure.

    1) Create a new table "Category" by "Enter data" with data "Beef" and "Dairy". (don't create any relationships)

    2) Create a measure.

    Measure = var cat = min('CategoryTableM2'[Category]) 
    	return sumx(
    		ADDCOLUMNS(
    			SUMMARIZE('Table1', 
    				Table1[HoldingID], 
    				"sumTemp", sum(Table1[percent_dairy])), 
    				"categoryTemp", if([sumTemp]>=80,"DAIRY","BEEF")),
    				if([categoryTemp] = cat, 1,0))

    Turning_a_measure_into_a_column

     

    Best Regards,

    Dale