Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
DauletKali
Helper I
Helper I

Return variant by two conditions

Hi guys, need help

I want to create measure that will return variant (3 column) if date (1 column) will equal to Today() - 1 (previousday) and item (2 column) will equal to specific text value, for example "Селитра аммиачная"

 

Снимок.PNG

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @DauletKali 

 

It’s my pleasure to answer for you.

You may be a little confused about measure and column, If you use column, you must keep the data types of true and false results consistent. Empty strings belong to text and you can omit them instead(blank()default).

Like this:

v-janeyg-msft_0-1602638389856.png

Or you can create a measure with selectedvalue.

Like this:

Measure =
IF (
    SELECTEDVALUE ( Table1[Date] ) = TODAY ()
        && SELECTEDVALUE ( Table1[Item] ) = "A",
    SELECTEDVALUE ( Table1[Quantity] ),
    ""
)

If it doesn’t solve your problems, please feel free to ask me.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @DauletKali 

 

It’s my pleasure to answer for you.

You may be a little confused about measure and column, If you use column, you must keep the data types of true and false results consistent. Empty strings belong to text and you can omit them instead(blank()default).

Like this:

v-janeyg-msft_0-1602638389856.png

Or you can create a measure with selectedvalue.

Like this:

Measure =
IF (
    SELECTEDVALUE ( Table1[Date] ) = TODAY ()
        && SELECTEDVALUE ( Table1[Item] ) = "A",
    SELECTEDVALUE ( Table1[Quantity] ),
    ""
)

If it doesn’t solve your problems, please feel free to ask me.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@DauletKali ,

As a new column , Use date and the other column that should be equal, column is option

sumx(filter(Table, [date] = earlier([date])-1 && [Column] = earlier([column])),[Value])

 

 

measure with date table


Day behind Sales = CALCULATE(SUM(Table[Value]),dateadd('Date'[Date],-1,Day))

This Day = CALCULATE(SUM(Table[Value]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(SUM(Table[Value]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(SUM(Table[Value]), previousday('Date'[Date]))

 

refer:Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

@amitchandak 

Thank for your quick response, but this does not work for my example

Let me show it in following example

 

I want to create a measure which will return "Quantity", IF Date will equal to TODAY and Item to, for example, A

Assume that today is 03/01/2020

 

DateItemQuantity
01.01.2020A100
02.01.2020B50
03.01.2020A20

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.