Forum Discussion
Dynamic value computation
Hello,
I am working on an assignment, and need help for a problem, which is like :
A user can come multiple times in a day and on different days and can use mobile or desktop for logging. so for the dates selected in the slicer, i have to compute each user only once and for all his logging entries if he has used only mobile for logging i should mark him under mobile category, if he has used only desktop for logging i should mark him under desktop category, but if he has used both i should mark him under both category.
For better understanding the data is like :
Date | User | Device
23/03/2018 | AAA | Mobile
24/04/2018 | AAA | Desktop
24/04/2018 | BBB | Desktop
25/04/2018 | BBB | Mobile
Desired output : if filter is on dates from 24/04/2018 to 25/04/2018
AAA | Desktop
BBB | Both
I am trying creating measure but not able to achieve it,
Any guidance would be of great help.
Thanks in advance!
7 Replies
- AnonymousNot applicable
Yes this can be done. First thing we need to do is create a "Key" field. Best place to do this is part of the import, but we could also do this as a calculated column in Dax. All you need to do is use the code "[User] & [Device]". The code is similar for Power Query and Dax in this regard.
Once you have the key column, you can create a label measure that looks like this:
Output Text = if( DISTINCTCOUNT(TestData[Key]) > 1, "Both", FIRSTNONBLANK(TestData[Device], TestData[Device]) )- nakul0490Frequent Visitor
Hey,
Many Thanks for the solution, it worked..
is there also a way to count on the output text the number of users? i tried doing it but it just uses the "Both" category
- AnonymousNot applicable
Are you able to rephrase your question? I'm not really sure what you means. Do you mean one of these:
Output Text = if( DISTINCTCOUNT(TestData[Key]) > 1, "Both (" & COUNT(TestData[User]) & ")", FIRSTNONBLANK(TestData[Device], TestData[Device]) )Output Text = if( DISTINCTCOUNT(TestData[Key]) > 1, "Both (" & DISTINCTCOUNT(TestData[User]) & ")", FIRSTNONBLANK(TestData[Device], TestData[Device]) )