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 All,
I have below dataset,
Where A,B & C are salesman in 1st column.
Where there is no value under sales column, it means salesman didnt woreked on that day.
For example, A didnt worked on 03/05, his total working days would be 3.
Simillarly i want to calcu
Solved! Go to Solution.
Hi @ashraf_SISL1,
Please unpivot the table as below in power query.
M code for your reference.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0NASRRsZAEswwVIrViVZyQhYEsY2NwOLOYC1GYNIEqh5EmijFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Salesman = _t, #"5/1/2019" = _t, #"5/2/2019" = _t, #"5/3/2019" = _t, #"5/4/2019" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Salesman", type text}, {"5/1/2019", Int64.Type}, {"5/2/2019", Int64.Type}, {"5/3/2019", Int64.Type}, {"5/4/2019", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Salesman"}, "Attribute", "Value")
in
#"Unpivoted Other Columns"
After that, we can create a measure as below and add it to matrix visual.
Measure =
IF (
ISFILTERED ( 'Table'[Attribute] ),
SUM ( 'Table'[Value] ),
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( 'Table', 'Table'[Attribute] <> BLANK () )
)
)
Attached the pbix as well.
Hi @ashraf_SISL1,
Please unpivot the table as below in power query.
M code for your reference.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0NASRRsZAEswwVIrViVZyQhYEsY2NwOLOYC1GYNIEqh5EmijFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Salesman = _t, #"5/1/2019" = _t, #"5/2/2019" = _t, #"5/3/2019" = _t, #"5/4/2019" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Salesman", type text}, {"5/1/2019", Int64.Type}, {"5/2/2019", Int64.Type}, {"5/3/2019", Int64.Type}, {"5/4/2019", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Salesman"}, "Attribute", "Value")
in
#"Unpivoted Other Columns"
After that, we can create a measure as below and add it to matrix visual.
Measure =
IF (
ISFILTERED ( 'Table'[Attribute] ),
SUM ( 'Table'[Value] ),
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( 'Table', 'Table'[Attribute] <> BLANK () )
)
)
Attached the pbix as well.