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
Anonymous
Not applicable

Dax measure: value from calculated column if condition is met, otherwise value 100

Hi!

 

I am wondering if it is possible to create the Desired value with a dax measure. I have a fact table with a Date and Transaction column. I have created a calcuated column and there is also a Date slicer. In the example below, the slicer value is on or after 1-1-2019

 

I am looking for a solution where I get a value of 100 if there hasn't been any buy transaction in the selected period. For example:

  • Between 1-1-2019 and 5-1-2019, there hasn't been a buy transaction registred. For those dates I want a value of 100
  • At 6-1-2019, there is a buy transaction. For this date and all following dates, I want the value from the calculated column.
  • If the slicer value is on or after 7-1-2019, the desired value is 100 for the dates from 7-1-2019 till the first buy transaction (somewhere in the future).

 

DateTransactionCalc. ColumnDesired value
1-1-2019 112100
2-1-2019 143100
3-1-2019sell100100
4-1-2019 100100
5-1-2019 100100
6-1-2019buy100100
7-1-2019 144144
8-1-2019 127127
9-1-2019 115115
10-1-2019 110110

 

Thank you for any help you can offer!

2 REPLIES 2
kentyler
Solution Sage
Solution Sage

How would the desired outcomes look if there was more than one seel/buy pair ? Can there be more than one sell/buy pair ?





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable

Hello @kentyler ,

 

Thanks for your responses, I hope this will clarify:

 

There are many buys and many sells. However a buy is always followed by a sell. And a sell is always followed by a buy. Below you will find the general structure of the table.

 

At the buy of sell date, the result of the calculated column has always a value of 100.

Between a sell and (the next) buy date, the result of the calculated column has always a value of 100.
Between a buy and (the next) sell date, the result of the calculated column varies.

 

Normally, the first transaction is always a buy transaction. However, when the Date slicer is used, it is possible that the first transaction is a sell. In this case, I am looking for a value of 100 instead of the result of the calculated column.

 

DateTransactionCalc. ColumnDesired value
24-9-2018 100100
25-9-2018 100100
26-9-2018buy100100
27-9-2018 100100
28-9-2018 9696
1-10-2018 9696
26-10-2018 9090
29-10-2018sell100100
30-10-2018 100100
1-2-2019 100100
4-2-2019 100100
5-2-2019 100100
6-2-2019buy100100
7-2-2019 9898
8-2-2019 9797
16-5-2019 103103
17-5-2019 101101
20-5-2019sell100100
21-5-2019 100100
24-7-2019buy100100
25-7-2019 101101
5-8-2019 9292
6-8-2019 9191
7-8-2019sell100100
8-8-2019 100100

 

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.