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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
AllanBerces
Post Partisan
Post Partisan

Confused what Dax formula to used

Hi Good day,

 

Can anyone help me how to write the correct formula base from my data. from the squence 1 code E0 = 0%, 2 code E2 = 9% and so on. buy from 13 to 31 all code = 100%.

SeqCodePercent
1E00%
2E29%
3M218%
4MN27%
5E336%
6E445%
7E4154%
8E4B63%
9E4E72%
10E4F81%
11E4G90%
12E4X100%
13M10100%
14E5100%
15E51100%
16E5A100%
17E6100%
18I0100%
19M12100%
20I0A100%
21I1100%
22I1A100%
23I2100%
24I3100%
25I4100%
26I5100%
27I6100%
28I7100%
29X7100%
30X7A100%
31M9100%

 

Thank you for the help

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @AllanBerces 

You can put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lc87DsMgEIThu1C7YBewQ5lITrSFU1tC3P8ayczQfSseP4yRLG3pzGluIznoZPnzEiv4JRs2FHIHK3mQRj/oF93pk7bM4a2BzfrRwGq9NbBreo6hfDaZ6aaIMd6eGpjfZeRjne68Sn/wzAWdcORDV7nTawH1WCcQD/3VEQ991tEOPcqRDqWd6UNG+pZLphUoKF89zfkD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Seq = _t, Code = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Seq", Int64.Type}, {"Code", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let _calculate=([Seq]-1)*0.09
in if _calculate<=1 then _calculate else 1),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Percentage.Type}})
in
    #"Changed Type1"

Output

vxinruzhumsft_0-1702886002367.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi @AllanBerces 

You can put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lc87DsMgEIThu1C7YBewQ5lITrSFU1tC3P8ayczQfSseP4yRLG3pzGluIznoZPnzEiv4JRs2FHIHK3mQRj/oF93pk7bM4a2BzfrRwGq9NbBreo6hfDaZ6aaIMd6eGpjfZeRjne68Sn/wzAWdcORDV7nTawH1WCcQD/3VEQ991tEOPcqRDqWd6UNG+pZLphUoKF89zfkD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Seq = _t, Code = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Seq", Int64.Type}, {"Code", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let _calculate=([Seq]-1)*0.09
in if _calculate<=1 then _calculate else 1),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Percentage.Type}})
in
    #"Changed Type1"

Output

vxinruzhumsft_0-1702886002367.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you very much

smpa01
Super User
Super User

@AllanBerces  you can do this

 

Measure 2 = 
var val = (MAX(t1[seq])-CALCULATE(MIN(t1[seq]),ALL(t1))) *0.09
return IF(val>1,1,val)
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.