Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi ,
Scenario- I have a Line Table (A in below pic) which has different orders and their lines for which certain number of days field is calculated. It has negative and positive numbers. The various possibilities are as shown below.
| A.Line Table | ||
| Order# | Line# | No of Days |
| ABC | 1 | -4
|
| ABC | 2 | -8 |
| ABC | 3 | -15 |
| DEF | 1 | 0 |
| XYZ | 1 | 3 |
| XYZ | 2 | 5 |
| XYZ | 3 | -10 |
| PQR | 1 | -8 |
| PQR | 2 | |
| PQR | 3 | 17 |
The above table which is at Line level is aggregated to Order level and another table exists in the Model which has all measures only at the Order level. In this Existing Order table I need to write a dax to get the below desired result of No of days -
Tried this dax - Doesnt seem to work! -
| B.Expected results( At Order level) | ||
| Order# | No of Days | |
| ABC | -15 | |
| DEF | 0 | |
| XYZ | -10 | |
| PQR |
Solved! Go to Solution.
@RRaj_293 try this measure: but you have to turn on show items with no data because when you are returning BLANK () where the
No of Days Measure =
VAR __MaxDays = MAXX ( Orders, [No of Days] )
VAR __MinDays = MINX ( Orders, [No of Days] )
VAR __CountBlank = COUNTROWS ( FILTER ( Orders, ISBLANK ( [No of Days] ) ) )
RETURN
IF ( __CountBlank >= 1, BLANK (), IF ( __MinDays < 0, __MinDays, __MaxDays ) )
Tweak the above measure as you see fit, as I didn't understand the full logic.
order has a blank number of days by default any visual will suppress that rows:
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you all for responding. I was able to resolve it using below dax-
@RRaj_293 Cannot tell, I tested on the sample you provided and it worked. You cannot compare with 0 because blank is deemed as zero and that's why I had that special logic in place to count the blank rows.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@RRaj_293 try this measure: but you have to turn on show items with no data because when you are returning BLANK () where the
No of Days Measure =
VAR __MaxDays = MAXX ( Orders, [No of Days] )
VAR __MinDays = MINX ( Orders, [No of Days] )
VAR __CountBlank = COUNTROWS ( FILTER ( Orders, ISBLANK ( [No of Days] ) ) )
RETURN
IF ( __CountBlank >= 1, BLANK (), IF ( __MinDays < 0, __MinDays, __MaxDays ) )
Tweak the above measure as you see fit, as I didn't understand the full logic.
order has a blank number of days by default any visual will suppress that rows:
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thanks @parry2k . I tried this and logically looks right to me as well but not sure why the records are all blank. I have enabled 'show items with No data'. If I remove the blank count and just do Min , Max it works except for blank scenarios.
Hi @lbendlin , Thanks for responding. Yes I got the same using If condition , but the challenge is with the blanks. I have modified the data in the table and the expected reuslts. If there is a combination of +ve , -ve and blank within an order then I need blank displayed at the order level as we are reporting the worst case scanerios . A blank indicates the order is not yet despatched likein order example PQR. If the order has only +ve and -ve's then display the min(farthest) negative number as that indiactes the most number of days taken(worst case scenario) like in example order XYZ.
Note - Table data edited for these scenarios in my original post.
Slightly refactored:
Order level =
var mxx = maxx('Table',[No of Days])
return if (mxx<0,minx('Table',[No of Days]),mxx)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 36 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 88 | |
| 74 | |
| 66 | |
| 65 |