Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello,
I am stuck with the code, please help me.
I am createing a calculated table using variables. At a certain step, I need to group leftjoined tables and create a calculated column "ActualDeliveryDate". The aim is populate the "ActuralDeliveryDate" column with the maximum delivery date for each SalesOrder, but only if there are no blank delivery dates for that SalesOrder. If there are any blank delivery dates, it replaces them with BLANK() using this code
"ActuralDeliveryDate",if(COUNTROWS(FILTER(join_tab,[SalesOrder] = EARLIER([SalesOrder]) && ISBLANK([ActualDeliveryDate]))) > 0, BLANK(),MAXX(CURRENTGROUP(),[ActualDeliveryDate])
1) when I use a groupby function, it does not work,
2) when I use summarise function, it works, but this code does not sum correctly.
"TotalQty", CALCULATE(SUMX(join_tab,[Quantity]))
Solved! Go to Solution.
Here is a working solution:
var group_tab =
ADDCOLUMNS(
SUMMARIZE(
join_tab,
[SalesOrder],
[OrderDate]),
"TotalQty", SUMX(FILTER(join_tab,[SalesOrder] = EARLIER([SalesOrder])),[Quantity]),
"ActuralDeliveryDate",if(COUNTROWS(FILTER(join_tab,[SalesOrder] = EARLIER([SalesOrder]) && ISBLANK([ActualDeliveryDate]))) > 0, BLANK(),MAXX(FILTER(join_tab,[SalesOrder] = EARLIER([SalesOrder]),[ActualDeliveryDate])
)
)
Here is a working solution:
var group_tab =
ADDCOLUMNS(
SUMMARIZE(
join_tab,
[SalesOrder],
[OrderDate]),
"TotalQty", SUMX(FILTER(join_tab,[SalesOrder] = EARLIER([SalesOrder])),[Quantity]),
"ActuralDeliveryDate",if(COUNTROWS(FILTER(join_tab,[SalesOrder] = EARLIER([SalesOrder]) && ISBLANK([ActualDeliveryDate]))) > 0, BLANK(),MAXX(FILTER(join_tab,[SalesOrder] = EARLIER([SalesOrder]),[ActualDeliveryDate])
)
)
Instead of trying to directly calculate the ActualDeliveryDate in a calculated table using variables, you might consider using measures to dynamically calculate it based on the context of your visuals.
can you provide sample data fo reference.
Learn Power BI free:
@AnalyticPulse
here is a link to sample pbi file
sample.pbix
I will not use this calculate table in any visual in power bi desktop. I will paste it to Powerbi report builder, and create a report.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
137 | |
70 | |
64 | |
52 | |
50 |
User | Count |
---|---|
208 | |
91 | |
62 | |
59 | |
56 |