Forum Discussion
dbehara
5 years agoFrequent Visitor
LODS on Power Bi
Hi Mate, Im totally new to Power BI and i'm try to switch from Tableau to Power BI. I have few LODS calculations created on Tableau and try to get those things on Power Bi but facing challenges, ...
- Anonymous5 years ago
Hi dbehara ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
First, please add custom column to get the date part of Date column in Power Query Editor and add Index column group by id and new custom column with date:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZVZc9owEMe/Ssv0oe3QiXZ1rEQeWoMxYC6DuSGdSdLmKdO3fv9qBSVuYrlPXsk/HXv9dTy2oNVu0Q3iDQqEdwAdpf3Mr9/Pz/6TdlEktnXX/g9XzoSZywhnwkbO2KU3hrk0lDWQ61QS8a9+brT41ECOR0T4nU8fOtS3VVKeSdtR9uWS4ROF+l20VnijmzoDhyqo/vV53wXpDt4YLIJTtaTmmc0QlNzx5gmAuKuS+kxSB6Wf6B2k0g/eGGWEStWArqOcn5jk2tjTEweypwR9i5OLHgi9YGNOwp1+CyF0nJ5NHImeN4rECTi14mS2MFqG7ciPDgk4+zlO531jDNOgOHJjMhTWNrg4S9BhWHLP5VBYbcPoZ80STgmvKTYI9hhyo5X9WCXtlZSVWpi9qoVX1H5HUpXM7RyKcGMZwfn46UbSOSZPtYX7giuusHztJPIx6dgpdYyQPFMMtDuHD0P4rDTvIzgDZY6kAh4KeU1K7yK4fIlFXhDg5fb1MOdu0JfOXiLRbq0SkHCpgvo13CmHvSPDWRzOEV07QnIdbVcKz45yF2z72ogGOulKKUbe2KUO7EM9qUVVTQZDQjtoIPdjROSUrzKrQjIh4lpo7d3IWMOCNh0aRWWE5KTMB04JDsJ2olEvG8hFRkQc63xFTn+NkBz+TV+5c6If+S4lat1UpGFNcrBktlxUBRp5H0isJa837i19VtIGMhuQxA+8ZC4tfomQqnp6uQRlbhtI33LaTDkKEwDVryfPbZeBIxatskCpqYFc+tAHcV/ujRXrBjLtKq0eqwpRzw37pIl7+JBpxItgvnWIZ5Y96yWVlWGSWkfbBnSzkRi0Gn7waKEMlBEczrgANraZFbYBLLryIgxPQSQlgavHw1vIhei4ACZeTuXp1IAmOTiTsJdeH4JSRnfmsI32Sohr4Y63AJA34Is1QngGDgUhVZryrZuc3d4IpLq+No2Vxni68jIT+ob/T72v+PedvPsD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, Date = _t, Case_id = _t, taskid = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"Date", type datetime}, {"Case_id", type text}, {"taskid", type text}}), #"Inserted Date" = Table.AddColumn(#"Changed Type", "NDate", each DateTime.Date([Date]), type date), #"Grouped Rows" = Table.Group(#"Inserted Date", {"id", "NDate"}, {{"Index", each Table.AddIndexColumn(_, "Index",1,1), type table}}), #"Expanded Index" = Table.ExpandTableColumn(#"Grouped Rows", "Index", {"Date", "Case_id", "taskid", "Index"}, {"Date", "Case_id", "taskid", "Index"}) in #"Expanded Index"Then create the below calculated columns to get Points/day and Task_created flag:
Points/day = VAR _countofcases = CALCULATE ( DISTINCTCOUNT ( 'Table'[Case_id] ), ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] ) ) VAR _minindex = CALCULATE ( MIN ( 'Table'[Index] ), ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] ) ) RETURN IF ( 'Table'[Index] = _minindex, IF ( _countofcases > 10, 1, 0 ), BLANK () )Task_created = VAR _countoftasks = CALCULATE ( DISTINCTCOUNT ( 'Table'[taskid] ), ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] ) ) VAR _minindex = CALCULATE ( MIN ( 'Table'[Index] ), ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] ) ) RETURN IF ( 'Table'[Index] = _minindex, IF ( _countoftasks >= 16, 3, IF ( _countoftasks >= 6, 2, 1 ) ), BLANK () )Best Regards
Anonymous
5 years agoNot applicable
Hi dbehara ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
First, please add custom column to get the date part of Date column in Power Query Editor and add Index column group by id and new custom column with date:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZVZc9owEMe/Ssv0oe3QiXZ1rEQeWoMxYC6DuSGdSdLmKdO3fv9qBSVuYrlPXsk/HXv9dTy2oNVu0Q3iDQqEdwAdpf3Mr9/Pz/6TdlEktnXX/g9XzoSZywhnwkbO2KU3hrk0lDWQ61QS8a9+brT41ECOR0T4nU8fOtS3VVKeSdtR9uWS4ROF+l20VnijmzoDhyqo/vV53wXpDt4YLIJTtaTmmc0QlNzx5gmAuKuS+kxSB6Wf6B2k0g/eGGWEStWArqOcn5jk2tjTEweypwR9i5OLHgi9YGNOwp1+CyF0nJ5NHImeN4rECTi14mS2MFqG7ciPDgk4+zlO531jDNOgOHJjMhTWNrg4S9BhWHLP5VBYbcPoZ80STgmvKTYI9hhyo5X9WCXtlZSVWpi9qoVX1H5HUpXM7RyKcGMZwfn46UbSOSZPtYX7giuusHztJPIx6dgpdYyQPFMMtDuHD0P4rDTvIzgDZY6kAh4KeU1K7yK4fIlFXhDg5fb1MOdu0JfOXiLRbq0SkHCpgvo13CmHvSPDWRzOEV07QnIdbVcKz45yF2z72ogGOulKKUbe2KUO7EM9qUVVTQZDQjtoIPdjROSUrzKrQjIh4lpo7d3IWMOCNh0aRWWE5KTMB04JDsJ2olEvG8hFRkQc63xFTn+NkBz+TV+5c6If+S4lat1UpGFNcrBktlxUBRp5H0isJa837i19VtIGMhuQxA+8ZC4tfomQqnp6uQRlbhtI33LaTDkKEwDVryfPbZeBIxatskCpqYFc+tAHcV/ujRXrBjLtKq0eqwpRzw37pIl7+JBpxItgvnWIZ5Y96yWVlWGSWkfbBnSzkRi0Gn7waKEMlBEczrgANraZFbYBLLryIgxPQSQlgavHw1vIhei4ACZeTuXp1IAmOTiTsJdeH4JSRnfmsI32Sohr4Y63AJA34Is1QngGDgUhVZryrZuc3d4IpLq+No2Vxni68jIT+ob/T72v+PedvPsD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, Date = _t, Case_id = _t, taskid = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"Date", type datetime}, {"Case_id", type text}, {"taskid", type text}}),
#"Inserted Date" = Table.AddColumn(#"Changed Type", "NDate", each DateTime.Date([Date]), type date),
#"Grouped Rows" = Table.Group(#"Inserted Date", {"id", "NDate"}, {{"Index", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
#"Expanded Index" = Table.ExpandTableColumn(#"Grouped Rows", "Index", {"Date", "Case_id", "taskid", "Index"}, {"Date", "Case_id", "taskid", "Index"})
in
#"Expanded Index"
Then create the below calculated columns to get Points/day and Task_created flag:
Points/day =
VAR _countofcases =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Case_id] ),
ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] )
)
VAR _minindex =
CALCULATE (
MIN ( 'Table'[Index] ),
ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] )
)
RETURN
IF ( 'Table'[Index] = _minindex, IF ( _countofcases > 10, 1, 0 ), BLANK () )Task_created =
VAR _countoftasks =
CALCULATE (
DISTINCTCOUNT ( 'Table'[taskid] ),
ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] )
)
VAR _minindex =
CALCULATE (
MIN ( 'Table'[Index] ),
ALLEXCEPT ( 'Table', 'Table'[id], 'Table'[NDate] )
)
RETURN
IF (
'Table'[Index] = _minindex,
IF ( _countoftasks >= 16, 3, IF ( _countoftasks >= 6, 2, 1 ) ),
BLANK ()
)
Best Regards