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 have this measure: # Products OOS = CALCULATE(DISTINCTCOUNT('Product'[Config_ID]), 'Product'[Stock Max date] = 0)
That has inside:
I want to pass 'Product'[Stock Max date] to a variable inside the measure # Products OOS. Can you help me?
Stock Max date = CALCULATE(SUM('Stock'[stock_quantity]), FILTER('Dim Date', 'Dim Date'[Date] = MAX('Dim Date'[Date])))
What am I trying?
Thanks
Diego
Hi, @carlovsky
Try this:
# Products OOS =
VAR Stock_Max_date =
ADDCOLUMNS(
stock,
"xD",
CALCULATE(
SUM( 'Stock'[stock_quantity] ),
FILTER( 'Dim Date', 'Dim Date'[Date] = MAX( 'Dim Date'[Date] ) )
)
)
VAR Products_OOS =
CALCULATE(
DISTINCTCOUNT( 'Product'[Config_ID] ),
FILTER( Stock_Max_date, [xD] = 1 )
)
RETURN
Products_OOS
If this doesn't work for you, could you please consider sharing more details about it.
It makes it easier to give you a solution.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-angzheng-msft
You don't know how incredible you are!!
Still have this issue with the below:
I have three CALCULATED COLUMNS :
average_is = CALCULATE(SUM(Sales[DF Items]), ALLSELECTED(ProdSup[Config_ID])) / 60
stock_max_date = CALCULATE(SUM('Stock'[stock_quantity]), FILTER('Dim Date', 'Dim Date'[Date] = MAX('Dim Date'[Date])))
flg_low_14d = IF(AND('Product'[Average IS]*14 > 'Product'[Stock Max date],'Product'[Stock Max date]>0) , 1, 0)
MEASURE:
# Prod coverage<14D = SUM('Product'[FLG_Low_14D])
How can I pass this inside a variable?
What I'm trying:
Hi, @carlovsky
Try this:
VAR prod_coverage_14d=SUMX(flg_low_14d,[@xD])
RETURN prod_coverage_14d
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @carlovsky
Try this:
IF ( AND(@average *14 > @stock_max, @stock_max >0),1,0)
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @carlovsky
Please consider sharing more details about it and posting expected result so it is clear on what needs to be implemented? And It would be great if there is a sample file without any sesentive information here.
How to Get Your Question Answered Quickly
It makes it easier to give you a solution.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-angzheng-msft ,
Just to remark, my main goal with this is to make some slicers work(Fullfillment type slicer from stock doesnt work because of the calculated columns).
You can find in the link below the sample:
Many thanks sir
Diego
Hi, @carlovsky
Try this:
VAR _average_is =
ADDCOLUMNS(
'Product',
"@average", CALCULATE( SUM( Sales[DF Items] ), ALLSELECTED( ProdSup[Config_ID] ) ) / 60,
"@stock_max",
CALCULATE(
SUM( 'Stock'[stock_quantity] ),
FILTER( 'Dim_Date', 'Dim_Date'[Date] = MAX( 'Dim_Date'[Date] ) )
)
)
VAR _flg_low_14d =
ADDCOLUMNS(
_average_is,
"@xD",
IF( AND( [@average] * 14 > [@stock_max], [@stock_max] > 0 ), 1, 0 )
)
VAR prod_coverage_14d =
SUMX(_flg_low_14d,[@xD])
RETURN
prod_coverage_14d
Result:
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Any suggestion on how to pass the calculated column to the variable ? Having hard time to filtet using slicers, because i am using calculated columns
HI @carlovsky
The ADDCOLUMNS is a tabular function and will return a table so you can not use that VAR in your calculation.
Read this: https://radacad.com/power-bi-dax-back-to-basics-scalar-vs-tabular-functions
Can yoiu share a sample of your data in a text format with relationships between your tables along with the expected result.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi @carlovsky , this part of your sode is not working "stock_max_date = 0". The reason is the stock_max_date is a Table; not a value. You would need to change to something like "FILTER ( stock_max_date , [xD] = 0 )". See if this works.
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 |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
42 | |
32 | |
30 | |
18 | |
18 |