Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi All,
i have table dataset in the below format,
ID | Date | App name | Duration |
100 | 01-12-2022 | METER | 10 |
100 | 01-12-2022 | 20 | |
101 | 01-12-2022 | FB | 20 |
102 | 01-12-2022 | METER | 10 |
100 | 02-12-2022 | METER | 10 |
101 | 02-12-2022 | 30 | |
102 | 02-12-2022 | METER | 10 |
100 | 03-12-2022 | 30 | |
101 | 03-12-2022 | METER | 10 |
101 | 03-12-2022 | 20 | |
102 | 04-12-2022 | METER | 10 |
First part was to calculate ATS = duration/distinctcount(ID) for each day excluding "METER" app. I used below DAX for the calculation
Solved! Go to Solution.
HI @Krishna_here,
You can use the following measure formula to check current id related records within current date ranges and return flag:
flag =
VAR currDate =
MAX ( 'Table'[Date] )
VAR appList =
CALCULATETABLE (
VALUES ( 'Table'[App name] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = YEAR ( currDate )
&& MONTH ( 'Table'[Date] ) = MONTH ( currDate )
),
VALUES ( 'Table'[ID] )
)
RETURN
IF ( "METER" IN appList && COUNTROWS ( appList ) = 1, "Y", "N" )
Regards,
Xiaoxin Sheng
Was able to solve above prob in SQL for one day taken at a time:
SELECT ID
FROM tabel
WHERE Date='2022-12-01'
GROUP BY ID
HAVING MIN(app name)=MAX(app name)
AND MIN(app name) in ('METER')
Can somebody help the above same in DAX method ?
HI @Krishna_here,
You can use the following measure formula to check current id related records within current date ranges and return flag:
flag =
VAR currDate =
MAX ( 'Table'[Date] )
VAR appList =
CALCULATETABLE (
VALUES ( 'Table'[App name] ),
FILTER (
ALLSELECTED ( 'Table' ),
YEAR ( 'Table'[Date] ) = YEAR ( currDate )
&& MONTH ( 'Table'[Date] ) = MONTH ( currDate )
),
VALUES ( 'Table'[ID] )
)
RETURN
IF ( "METER" IN appList && COUNTROWS ( appList ) = 1, "Y", "N" )
Regards,
Xiaoxin Sheng
Thank you so much for the response. So i was applying the same measure that you have given but my actual dataset is huge so keeping ID, app name and date is not loading the measure. (data that i pasted in question was just a sample).
Is it possible to show the flag against each ID in visual avoiding the app and date from the visual ?
Hi @Krishna_here,
In fact, this expression will check at the year month level based on current ID group.
If you only use ID as category without other fields, the formula will get wrong results because the aggregate row contexts have matched with multiple type of flags.
Regards,
Xiaoxin Sheng
User | Count |
---|---|
52 | |
51 | |
20 | |
17 | |
16 |
User | Count |
---|---|
113 | |
46 | |
44 | |
28 | |
22 |