Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
The following is the sample dataset of my actual dataset:
Device | Status | Datetime |
A | Good | 10/23/2020 8:10:00 AM |
A | Faulty | 10/23/2020 4:15:00 PM |
A | Good | 10/24/2020 11:10:00 AM |
B | Good | 10/23/2020 8:10:00 AM |
B | Good | 10/23/2020 4:15:00 PM |
B | Faulty | 10/24/2020 11:10:00 AM |
C | Faulty | 10/23/2020 8:10:00 AM |
C | Good | 10/23/2020 4:15:00 PM |
C | Faulty | 10/24/2020 11:10:00 AM |
I have to display those device's names which latest status is faulty.
I tried unsuccessfuly the below dax to create a measure:
Solved! Go to Solution.
HI @jitpbi,
It seems like I forget to pack it with aggregate functions, please try this one if it works:
faulty_device =
VAR currSatatus =
SELECTEDVALUE ( 'Table'[Status] )
VAR _lastDate =
CALCULATE (
MAX ( Equipment[DateTime] ),
ALLSELECTED ( Table ),
VALUES ( 'Table'[Device] )
)
RETURN
IF (
currSatatus = " Faulty"
&& MAX( Table[DateTime] ) = _lastDate,
CONCATENATEX ( VALUES ( Table[Device] ), [Device], "is faulty device" ),
"No Device is faulty Currently"
)
Regards,
Xiaoxin Sheng
Hi @jitpbi,
You can try to use the following measure formula if it works on your side:
faulty_device =
VAR currSatatus =
SELECTEDVALUE ( 'Table'[Status] )
VAR _lastDate =
CALCULATE (
MAX ( Equipment[DateTime] ),
ALLSELECTED ( Table ),
VALUES ( 'Table'[Device] )
)
RETURN
IF (
currSatatus = " Faulty"
&& Table[DateTime] = _lastDate,
CONCATENATEX ( VALUES ( Table[Device] ), [Device], "is faulty device" ),
"No Device is faulty Currently"
)
If this not help, please share some dummy data to test coding formula.
Regards,
Xiaoxin Sheng
Hi @v-shex-msft ,
When trying to use the measure formula you shared, it is not accepting Table[DateTime] in the formula.
HI @jitpbi,
It seems like I forget to pack it with aggregate functions, please try this one if it works:
faulty_device =
VAR currSatatus =
SELECTEDVALUE ( 'Table'[Status] )
VAR _lastDate =
CALCULATE (
MAX ( Equipment[DateTime] ),
ALLSELECTED ( Table ),
VALUES ( 'Table'[Device] )
)
RETURN
IF (
currSatatus = " Faulty"
&& MAX( Table[DateTime] ) = _lastDate,
CONCATENATEX ( VALUES ( Table[Device] ), [Device], "is faulty device" ),
"No Device is faulty Currently"
)
Regards,
Xiaoxin Sheng
@jitpbi , what the relationship with Table and Equipment (cardinality and direction)? As you know, relationship plays a critical role when authoring measures.
For the moment, I came up with a measure based on the single table like this,
Faulty Devices =
VAR __tb =
FILTER (
FILTER (
'Table',
'Table'[Datetime]
= CALCULATE ( MAX ( 'Table'[Datetime] ), ALLEXCEPT ( 'Table', 'Table'[Device] ) )
),
'Table'[Status] = "Faulty"
)
RETURN
CONCATENATEX ( __tb, 'Table'[Device], UNICHAR ( 10 ) )
When dragged into a card viz, it returns
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@jitpbi
Add the following measure;
Faulty Devices =
VAR __STATUS = LASTNONBLANKVALUE(Table5[Datetime],MAX(Table5[Status])) RETURN
IF( __STATUS = "Faulty", __STATUS , BLANK() )
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
99 | |
86 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |