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.
I have a table of data that looks like:
ID | Sdate | Pdate | Ddate | Dstatus |
22A0B3A9 | ||||
6B63C304 | 9/21/2018 9:39 | 1/8/2019 8:34 | ||
4E1C2014 | ||||
29970ABD | ||||
B59F6194 | 10/1/2018 23:01 | 10/1/2018 23:10 | 1/30/2019 10:42 | Accept |
76DA99FA | 11/27/2018 14:39 | 11/27/2018 14:48 | 1/8/2019 10:47 | Accept |
E7F024E0 |
I am trying to add a Results Column based on a slicer date value (in this case the date slice value is 12/18/18) that would make the data look like:
ID | Sdate | Pdate | Ddate | Dstatus | Result |
22A0B3A9 | |||||
6B63C304 | 9/21/2018 9:39 | 1/8/2019 8:34 | Pending | ||
4E1C2014 | 10/1/2018 23:01 | 10/1/2018 23:10 | 1/30/2019 10:42 | Accept | Accept |
29970ABD | 11/27/2018 14:39 | 11/27/2018 14:48 | 1/8/2019 10:47 | Accept | Pending |
B59F6194 | 11/27/2018 14:39 | 11/27/2018 14:48 | 1/8/2019 10:47 | Pending | |
76DA99FA | 10/3/2018 14:40 | 10/3/2018 14:42 | 12/17/2018 11:31 | Conditional Accept | Conditional Accept |
E7F024E0 | 1/9/2019 18:49 | 1/9/2019 18:49 | 1/10/2019 11:37 | Accept | |
9FA36508 | 8/22/2018 18:28 | 8/22/2018 18:33 | Pending |
If I was doing this in Excel, my formula would be =IF(AND([Ddate]<>"",[Ddate]<=12/18/18),[Dstatus],IF(AND([Pdate]]<>"",[Pdate]<=12/18/18),"Pending",IF(AND([Sdate]<>"",[Sdate]<=12/18/18),"Pending","")))
In DAX I am able build the logic in the proper DAX format, but the return value I am getting in the Measure is a not a text value. I actually get an error because it is says it is comparing Date types to Text types.
While this isn't the full DAX forumla, it is the one I am testing for at least the first step in the comparison:
St =
IF (
AND (
( MIN ( TableA[Ddate] ) <> "" ),
( MIN ( TableA[Ddate] ) <= TableA[SlicerDateSelected] )
),
MINA ( SlateAppData[Dstatus] ),
""
)
[SlicerDateSelected] is just the Max value from a slicer on a date table I have created.
What I am missing?
Solved! Go to Solution.
Figured my problem out. It wasn't an issue with the getting the result as a text value but my problem was the comparison was trying to compare date and text types. Instead I used the following to achieve what I needed. I was comparing a Date field to "" to determine if not blank. Everything worked fine once I used the BLANK() function instead in the comparison.
St =
SWITCH (
TRUE (),
AND (
MINA ( TableA[Ddate] ) <> BLANK (),
MINA ( TableA[Ddate] ) <= [SlicerDateSelected]
), MINA ( TableA[Dstatus] ),
AND (
MINA ( TableA[Pdate] ) <> BLANK (),
MINA ( TableA[Pdate] ) <= [SlicerDateSelected]
), "Pending",
AND (
MINA ( TableA[Sdate] ) <> BLANK (),
MINA ( TableA[Sdate] ) <= [SlicerDateSelected]
), "Pending",
""
)
Figured my problem out. It wasn't an issue with the getting the result as a text value but my problem was the comparison was trying to compare date and text types. Instead I used the following to achieve what I needed. I was comparing a Date field to "" to determine if not blank. Everything worked fine once I used the BLANK() function instead in the comparison.
St =
SWITCH (
TRUE (),
AND (
MINA ( TableA[Ddate] ) <> BLANK (),
MINA ( TableA[Ddate] ) <= [SlicerDateSelected]
), MINA ( TableA[Dstatus] ),
AND (
MINA ( TableA[Pdate] ) <> BLANK (),
MINA ( TableA[Pdate] ) <= [SlicerDateSelected]
), "Pending",
AND (
MINA ( TableA[Sdate] ) <> BLANK (),
MINA ( TableA[Sdate] ) <= [SlicerDateSelected]
), "Pending",
""
)
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 |
---|---|
114 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |