Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The 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.

Reply
ase
Frequent Visitor

Help with dax formula to normalize order values

Hello, 

 

I have a problem to write a DAX formula which normalizes invoice data: 

 

ase_0-1657637873271.png

 

I have data on the products that were ordered and the products that were received instead ( when the substitute is empty, it means that there was no substitute. 

 

Can someone help me with a Dax formula, which shows the most substituted products in a normalized way. (like under the yellow bar)

 

Thank you very much in advance!

Kind regards,

B.

 

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Hi @ase 

I'm not totally sure what you mean by normalized, but here's some measures to help you out.  These give you numbers, so can be used in charts.

Order Count = COUNTROWS('Table')

Substituted Order Count = SUM('Table'[Is substituted])

Substituted Percent = DIVIDE([Substituted Order Count], [Order Count])

if you want the specific text in your example then we can have measures to build that text up.

Text 1 = 
VAR _Product = SELECTEDVALUE('Table'[Ordered product], "Multiple products")
VAR _Result = 
_Product & " " & [Order Count] & " orders total, " & [Substituted Order Count] & " substituted"
RETURN
    _Result
Text 2 = 
VAR _Product = SELECTEDVALUE('Table'[Ordered product], "Multiple products")
VAR _Result = 
_Product & " " & FORMAT([Substituted Percent] * 100, "#,0") & "% substituted"
RETURN
    _Result

 

PaulOlding_0-1657642892226.png

 

 

View solution in original post

3 REPLIES 3
ase
Frequent Visitor

Hi @PaulOlding 

 

The idea was to show that in XX% of the cases, apples were substituted with another product.
The rationale for normalization part comes from the fact that for example we might have ordered 10 apples and 9 of them might have been substituted, and at the same time we might have ordered 1000 oranges, with 350 substituted, so I need to factor for the amount of the products. 

 

Unfortunately your solution only gives the number of substitutuions, but not the normalized ratio between ordered apples and times they were substituted.

 

Kind regards,

B.

Hi @ase 

The 'Substituted Percent' measure gives the ratio.

PaulOlding
Solution Sage
Solution Sage

Hi @ase 

I'm not totally sure what you mean by normalized, but here's some measures to help you out.  These give you numbers, so can be used in charts.

Order Count = COUNTROWS('Table')

Substituted Order Count = SUM('Table'[Is substituted])

Substituted Percent = DIVIDE([Substituted Order Count], [Order Count])

if you want the specific text in your example then we can have measures to build that text up.

Text 1 = 
VAR _Product = SELECTEDVALUE('Table'[Ordered product], "Multiple products")
VAR _Result = 
_Product & " " & [Order Count] & " orders total, " & [Substituted Order Count] & " substituted"
RETURN
    _Result
Text 2 = 
VAR _Product = SELECTEDVALUE('Table'[Ordered product], "Multiple products")
VAR _Result = 
_Product & " " & FORMAT([Substituted Percent] * 100, "#,0") & "% substituted"
RETURN
    _Result

 

PaulOlding_0-1657642892226.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.