Forum Discussion
DAX formula
- Anonymous2 years ago
Hi V3Rn3r_8-6
Use measure instead of calculate column, pbix file attached.Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous2 years ago
Hi V3Rn3r_8-6
Please try the following calculate column:
Realllll = VAR _count = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Date]=EARLIER('Table'[Date]))) RETURN IF ( CALCULATE ( SUM ( 'Table'[Total Orders on shift] ), FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER('Table'[Name]) && 'Table'[Shift] = "O" &&'Table'[Date]=EARLIER('Table'[Date]) ) ) > CALCULATE ( SUM ( 'Table'[Total Orders on shift] ), FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER('Table'[Name]) && 'Table'[Shift] = "N" &&'Table'[Date]=EARLIER('Table'[Date]) ) ), _count&"x"&"O", IF ( CALCULATE ( SUM ( 'Table'[Total Orders on shift] ), FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER('Table'[Name]) && 'Table'[Shift] = "N" &&'Table'[Date]=EARLIER('Table'[Date]) ) ) > CALCULATE ( SUM ( 'Table'[Total Orders on shift] ), FILTER ( ALL ( 'Table' ), 'Table'[Name] = EARLIER('Table'[Name]) && 'Table'[Shift] = "R" &&'Table'[Date]=EARLIER('Table'[Date]) ) ), _count&"x"&"N", _count&"x"&"R" ) )Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi V3Rn3r_8-6
Please try the following measure:
HReal =
VAR select_date =
SELECTEDVALUE ( 'Table'[Datum ZN] )
VAR select_smena =
SELECTEDVALUE ( 'Table'[Smena 45-45] )
RETURN
IF (
CALCULATE (
SUM ( 'Table'[Total Orders on shift] ),
FILTER (
ALL ( 'Table' ),
'Table'[Datum ZN] = select_date
&& 'Table'[Smena 45-45] = "O"
)
)
> CALCULATE (
SUM ( 'Table'[Total Orders on shift] ),
FILTER (
ALL ( 'Table' ),
'Table'[Datum ZN] = select_date
&& 'Table'[Smena 45-45] = "N"
)
),
"O",
IF (
CALCULATE (
SUM ( 'Table'[Total Orders on shift] ),
FILTER (
ALL ( 'Table' ),
'Table'[Datum ZN] = select_date
&& 'Table'[Smena 45-45] = "N"
)
)
> CALCULATE (
SUM ( 'Table'[Total Orders on shift] ),
FILTER (
ALL ( 'Table' ),
'Table'[Datum ZN] = select_date
&& 'Table'[Smena 45-45] = "R"
)
),
"N",
"R"
)
)
Result:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello,
Thank you very much for your help, only in this case it always returns "R" because every day most orders are always made on the morning shift. I would need if it would be possible to use another column with the names of the people, so that the shift is listed separately for each of them. If someone has a night shift and makes an order on the afternoon shift, have this formula list the night shift everywhere as I wrote before and do the same for different people and different shifts.
("R" morning shift, "O" afternoon shift, "N" night shift)
Thank you very much
- Anonymous2 years agoNot applicable
Hi V3Rn3r_8-6
Please provide sample data that fully covers your issue and the expected outcome based on the sample data you provided.
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.