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.
Hi All,
I am literally pulling my hair to get the measure right. I have tried different ways and currently stuck. The logic is quite basic but the issue is with reading the date column . Let me elaborate the measure I am looking for.
The shortage column in the below table is a measure and Date is a column coming from the model. The logic I am looking for is If shortage =1 , planned dates else blank.
The point that I am stuck at is, As i am trying to build a measure using IF , to read the date column I am using Min or Max functions, which is returning the min or max date instead of returning the 2 dates for particular product and location.
The measure that I have tried.
Product | Location | Date | Beg_inv | Shortage |
402390 | 1223 | 07-10-2022 | 70 | 0 |
402390 | 1223 | 08-11-2022 | -5 | 1 |
402390 | 1223 | 08/13/2022 | 25 | 0 |
402390 | 1223 | 08/14/2022 | 30 | 0 |
402390 | 1223 | 08/15/2022 | -15 | 1 |
402390 | 1223 | 08/17/2022 | -2 | 0 |
402390 | 1223 | 08/18/2022 | 7 | 0 |
402390 | 1223 | 08/20/2022 | 30 | 0 |
Product | Location | Planned Dates |
402390 | 1223 | 08-11-2022 |
Product | Location | Date | Beg_inv | Shortage | Planned_Dates |
402390 | 1223 | 07-10-2022 | 70 | 0 | |
402390 | 1223 | 08-11-2022 | -5 | 1 | 08-11-2022 |
402390 | 1223 | 08/13/2022 | 25 | 0 | |
402390 | 1223 | 08/14/2022 | 30 | 0 | |
402390 | 1223 | 08/15/2022 | -15 | 1 | 08-15-2022 |
402390 | 1223 | 08/17/2022 | -2 | 0 | |
402390 | 1223 | 08/18/2022 | 7 | 0 | |
402390 | 1223 | 08/20/2022 | 30 | 0 |
Product | Location | Planned Dates |
402390 | 1223 | 08-11-2022 |
402390 | 1223 | 08-15-2022 |
Hope someone finds a solution for this.
Thnaks in advance.
@tamerj1 @amitchandak @lbendlin @parry2k
Solved! Go to Solution.
Hello agian @Anonymous
I think the following solution complies more with your requirement. Please refer to attached file
Place the measure in the filter pane and select "Is not blank" then apply the filter.
Planned_Dates =
VAR CurrentDate = MAX ( 'Table'[Date] )
VAR T1 = FILTER ( VALUES ( 'Table'[Date] ), [Beg_Inv] < 0 && [Sortage] = 1 )
RETURN
IF ( CurrentDate IN T1, CurrentDate )
Hello agian @Anonymous
I think the following solution complies more with your requirement. Please refer to attached file
Place the measure in the filter pane and select "Is not blank" then apply the filter.
Planned_Dates =
VAR CurrentDate = MAX ( 'Table'[Date] )
VAR T1 = FILTER ( VALUES ( 'Table'[Date] ), [Beg_Inv] < 0 && [Sortage] = 1 )
RETURN
IF ( CurrentDate IN T1, CurrentDate )
Hi @Anonymous
Please cl;arify as below
*Update
I mean you have two tables.
Hi @tamerj1
Sorry for not Providing the measure in right way.
Forgot to edit the measure properly.
Apologies again!
@Anonymous
The following shall satisfy this requirement in a different way
Planned_Dates =
VAR T1 = FILTER ( 'Table', [Beg_Inv] < 0 && [Sortage] = 1 )
RETURN
CONCATENATEX ( T1, [Date], UNICHAR ( 10 ) )
Hi @Anonymous
I think your problrm id having columns of two dim tables in the same visual . You did not present any information about data model but let me try to guide you through following an example: Let's say the Product ID is comming from the product table (Products[Product ID]) and the fact table date column is Fact[Date] which is filtered by 'Date'[Date] which is the column that you are using in your visual. In this case the DAX to retrieve the date in the current filter context would be
CALCULATE ( MAX ( 'Date'[Date] ), CROSSFILTER ( 'Date'[Date], Fact[Date], BOTH ) )
Or simply
MAX ( Fact[Date] )
Hi @tamerj1
Can I know if there is any possibility of creating a calculated column in this case.
Where in I find trouble in calculating a column including measures in it. There a circualar dependency error popping up every single time I try creating a column.
The entire data i.e. all the columns and measures are coming from the same table which is the fact table.
@Anonymous
Sorry, I got busy with other business.
I think I did not read properly. Let me check and give it a try
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
98 | |
97 | |
75 | |
71 | |
64 |
User | Count |
---|---|
143 | |
109 | |
103 | |
82 | |
74 |