Forum Discussion
Count status values based on slicer selected dates duration
- Anonymous4 years ago
Hi Haripoola ,
In your calculation, you have two keys, InstallationJob and LaptopID. I suggest you to create a calculated column to combine them to one column. This will make calculation easier.
Combine Key Column = COMBINEVALUES("-",'Table'[InstallationJob],'Table'[LaptopID])Measure:
Count = VAR _Installed_Key = CALCULATETABLE ( VALUES ( 'Table'[Combine Key Column] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[InstalledStatus] = "Installed" ) ) VAR _CountRows = CALCULATE ( COUNTROWS ( 'Table' ) ) RETURN IF ( HASONEVALUE ( 'Table'[InstalledStatus] ), SWITCH ( MAX ( 'Table'[InstalledStatus] ), "Deployed", _CountRows, "Failed", CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', NOT ( 'Table'[Combine Key Column] IN _Installed_Key ) ) ), "Installed", _CountRows, "SWError", CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', NOT ( 'Table'[Combine Key Column] IN _Installed_Key ) ) ) ), DISTINCTCOUNT ( 'Table'[Combine Key Column] ) )Result is as below.
12/01/21 to 03/14/22:
12/01/21 to 03/13/22
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Haripoola ,
In your calculation, you have two keys, InstallationJob and LaptopID. I suggest you to create a calculated column to combine them to one column. This will make calculation easier.
Combine Key Column = COMBINEVALUES("-",'Table'[InstallationJob],'Table'[LaptopID])
Measure:
Count =
VAR _Installed_Key =
CALCULATETABLE (
VALUES ( 'Table'[Combine Key Column] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[InstalledStatus] = "Installed" )
)
VAR _CountRows =
CALCULATE ( COUNTROWS ( 'Table' ) )
RETURN
IF (
HASONEVALUE ( 'Table'[InstalledStatus] ),
SWITCH (
MAX ( 'Table'[InstalledStatus] ),
"Deployed", _CountRows,
"Failed",
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( 'Table', NOT ( 'Table'[Combine Key Column] IN _Installed_Key ) )
),
"Installed", _CountRows,
"SWError",
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( 'Table', NOT ( 'Table'[Combine Key Column] IN _Installed_Key ) )
)
),
DISTINCTCOUNT ( 'Table'[Combine Key Column] )
)
Result is as below.
12/01/21 to 03/14/22:
12/01/21 to 03/13/22
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Thank you for your solution, it worked for me.