Forum Discussion

Applicable88's avatar
Applicable88
Icon for Impactful Individual rankImpactful Individual
5 years ago
Solved

Datediff and row context

Hello, 

 

I have question regarding the datediff() function. In the syntax it is not mentioned that its a iterator. But why it works in a measure like this:

Ampel =
VAR _dur =
DATEDIFF (
MAX( Orders[Date] ),
Max(LastRefresh[LastRefreshUTC]),
DAY
)
RETURN
SWITCH (
TRUE (),
_dur < 0, "#09ff00", /Greencoulor
_dur =0, "#ffdd00",//Yellocolour
"#ff0000" //Redcolour
 
If i would put it directly like this:
if ( Order[Date]< today()...... and so fourth
its not going to work since its like comparing to a "naked column" and the fields are grayed out.
 
Even the max(order[date]) above is actually delivering a scalar value and shoulnd't it only consist of the last date available in my date table?
 
Best.  
  • Applicable88 not sure if I fully understood your question. MAX date will not necessarily return the MAX date in your calendar table it will return in the row filter context.

     

    If you are looking at the data at the month level, the max date will of that month, the same data you are looking at by week, the max date will be the max of that week, and so forth so on.

     

    It is always good to provide some sample data and how you are visualizing to provide more context to the problem. MAX date doesn't mean anything until you define in what context you are looking at it.

3 Replies

  • Applicable88 not sure if I fully understood your question. MAX date will not necessarily return the MAX date in your calendar table it will return in the row filter context.

     

    If you are looking at the data at the month level, the max date will of that month, the same data you are looking at by week, the max date will be the max of that week, and so forth so on.

     

    It is always good to provide some sample data and how you are visualizing to provide more context to the problem. MAX date doesn't mean anything until you define in what context you are looking at it.

  • Applicable88 where you see it says iterator, it takes scalar values

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

    • Applicable88's avatar
      Applicable88
      Icon for Impactful Individual rankImpactful Individual

      Hi parry2k , thats the question. Since its not a iterator function and only put in a variable inside a measure, how can it operate? isn't it comparing one naked column two another naked column this way?  

       

      It't the same like  when you want to use the If-statements  in a measure, it only works when wrapped up inside the conditional part of a another x-aggregated function.