Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I try to create a measure that count how many customer had their shipment on time (All Shipments on time) in this year
Example data
Customer | ExpectShipmentDate | ShipmentDate | Datediff | |||
Customer 1 | 2023-03-01 | 2023-03-01 | 0 | |||
Customer 1 | 2023-03-03 | 2023-03-03 | 0 | |||
Customer 2 | 2023-03-01 | 2023-03-02 | 1 | |||
Customer 2 | 2023-03-03 | 2023-03-03 | 0 | |||
Customer 3 | 2023-03-01 | 2023-03-03 | 2 | |||
Customer 3 | 2023-03-03 | 2023-03-04 | 1 |
Only Cumtomer 1 had all shipments on time so my measure should return 1
I try something like this:
COUNTROWS(
FILTER (
SUMMARIZE(
'Table',
'Table'[Customer]
, "Datediff"
,CALCULATE(SUM('Table'[Datediff]),
YEAR('Table'[ShipmentDate])=year(today()))
)
,"Datediff"=0
)
)
In my opinion it should works, but i Have this error:
MdxScript(Model) (68, 18) DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.
Solved! Go to Solution.
Hi @jurkowskij
1.Please check that the data type of your ShipmentDate column or datediff column, whether the type is "Text" instead of "Date" or "Whole number".
2.You can refer to the following measure
Measure = var a=SUMMARIZE(
'Table',
'Table'[Customer]
, "Sum",SUM('Table'[Datediff])
)
return COUNTROWS(FILTER(a,[Sum]=0))
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @jurkowskij
1.Please check that the data type of your ShipmentDate column or datediff column, whether the type is "Text" instead of "Date" or "Whole number".
2.You can refer to the following measure
Measure = var a=SUMMARIZE(
'Table',
'Table'[Customer]
, "Sum",SUM('Table'[Datediff])
)
return COUNTROWS(FILTER(a,[Sum]=0))
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
It seems to work. thanks a lot
User | Count |
---|---|
59 | |
59 | |
56 | |
38 | |
29 |
User | Count |
---|---|
77 | |
62 | |
45 | |
40 | |
39 |