Forum Discussion
Pivot data
- 8 years ago
Hi bsushy,
As the Cancer Column, Diabetes and Hypertension Columns are calculated columns, they won't appear in Query Editor. So the Pivot option is not available here.
Based on my test, you can firstly use the formula below to create a new table which has a column of Chronic Condition Types.
Chronic Condition = DATATABLE ( "Chronic Condition Type", STRING, { { "Cancer" }, { "Diabetes" }, { "Hypertension" } } )Then you should be able to use the formula below to create a new measure to calculate distinct count of MemberID for each Chronic Condition Type from your original table('Table1').
Measure = IF ( HASONEVALUE ( 'Chronic Condition'[Chronic Condition Type] ), SWITCH ( VALUES ( 'Chronic Condition'[Chronic Condition Type] ), "Cancer", CALCULATE ( DISTINCTCOUNT ( Table1[MemberID] ), Table1[Cancer Column] = "cancer" ), "Hypertension", CALCULATE ( DISTINCTCOUNT ( Table1[MemberID] ), Table1[Hypertension Column] = "hypertension" ), "Diabetes", CALCULATE ( DISTINCTCOUNT ( Table1[MemberID] ), Table1[Diabetes Column] = "diabetes" ) ) )And then you can show the 'Chronic Condition'[Chronic Condition Type] as Axis, and the measure as Value to get your expected result. :smileyhappy:
Regards
Hi bsushy,
As the Cancer Column, Diabetes and Hypertension Columns are calculated columns, they won't appear in Query Editor. So the Pivot option is not available here.
Based on my test, you can firstly use the formula below to create a new table which has a column of Chronic Condition Types.
Chronic Condition =
DATATABLE (
"Chronic Condition Type", STRING,
{
{ "Cancer" },
{ "Diabetes" },
{ "Hypertension" }
}
)
Then you should be able to use the formula below to create a new measure to calculate distinct count of MemberID for each Chronic Condition Type from your original table('Table1').
Measure =
IF (
HASONEVALUE ( 'Chronic Condition'[Chronic Condition Type] ),
SWITCH (
VALUES ( 'Chronic Condition'[Chronic Condition Type] ),
"Cancer", CALCULATE (
DISTINCTCOUNT ( Table1[MemberID] ),
Table1[Cancer Column] = "cancer"
),
"Hypertension", CALCULATE (
DISTINCTCOUNT ( Table1[MemberID] ),
Table1[Hypertension Column] = "hypertension"
),
"Diabetes", CALCULATE (
DISTINCTCOUNT ( Table1[MemberID] ),
Table1[Diabetes Column] = "diabetes"
)
)
)
And then you can show the 'Chronic Condition'[Chronic Condition Type] as Axis, and the measure as Value to get your expected result. :smileyhappy:
Regards
Thank you:)