Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi,
I need to calculate Percentage in power query. If Country = India then (Available - (DowntimeHrs/7.5)- Required)/Required ) and for other country (Available - (DowntimeHrs/6.5)- Required)/Required )
IFERROR(IF($A2="India",($B2-($C2/7.5)-$D2)/$D2,($B2-($C2/6.5)-$D2)/$D2),"")
Country | Available | DowntimeHrs | Required | Percentage% |
Philippines | 15.00 | 0.00 | 18.00 | -16.7% |
India | 14.00 | 2.25 | 14.00 | -2.1% |
Japan | 42.00 | 0.00 | 44.00 | -4.5% |
India | 27.00 | 0.00 | 31.00 | -12.9% |
India | 5.00 | 0.00 | 5.00 | 0.0% |
India | 20.00 | 0.00 | 20.00 | 0.0% |
India | 1.00 | 0.00 | 1.00 | 0.0% |
India | 3.50 | 0.00 | 5.00 | -30.0% |
India | 0.50 | 0.00 | 1.00 | -50.0% |
India | 1.00 | 0.00 | 1.00 | 0.0% |
India | 0.50 | 0.00 | 1.00 | -50.0% |
India | 1.00 | 0.00 | 1.00 | 0.0% |
India | 2.00 | 0.00 | 2.00 | 0.0% |
India | 4.00 | 0.00 | 4.00 | 0.0% |
India | 6.00 | 0.00 | 6.00 | 0.0% |
India | 12.00 | 0.00 | 12.00 | 0.0% |
India | 14.00 | 0.00 | 16.00 | -12.5% |
India | 5.00 | 0.00 | 5.00 | 0.0% |
India | 5.00 | 4.00 | 4.40 | 1.5% |
India | 3.00 | 0.00 | 1.50 | 100.0% |
India | 12.00 | 38.57 | 6.00 | 14.3% |
India | 9.00 | 7.00 | 1.00 | 706.7% |
Japan | 7.00 | 12.14 | 2.26 | 127.1% |
Japan | 11.00 | 0.00 | 1.17 | 840.2% |
Japan | 2.00 | 0.26 | 0.00 | |
Japan | 4.00 | 0.26 | 0.81 | 388.9% |
Japan | 2.00 | 1.05 | 3.97 | -53.7% |
Japan | 4.00 | 0.00 | 0.53 | 654.7% |
Japan | 6.00 | 38.57 | 1.52 | -95.6% |
Japan | 3.00 | 0.00 | 4.33 | -30.7% |
Japan | 28.50 | 0.00 | 0.00 | |
Japan | 14.00 | 0.00 | 1.16 | 1106.9% |
Japan | 11.50 | 0.00 | 3.00 | 283.3% |
Japan | 15.50 | 3.00 | 416.7% | |
Japan | 4.00 | 10.00 | 0.00 | |
Japan | 148.00 | 0.00 | 3.00 | 4833.3% |
Japan | 2.00 | 0.00 | 29.00 | -93.1% |
Japan | 8.00 | 0.00 | 2.00 | 300.0% |
Japan | 4.60 | 0.00 | 2.00 | 130.0% |
Japan | 0.40 | 0.00 | 26.00 | -98.5% |
Philippines | 72.00 | 0.00 | 69.00 | 4.3% |
Philippines | 107.00 | 0.00 | 5.90 | 1713.6% |
Philippines | 10.00 | 0.48 | 2.00 | 396.3% |
Philippines | 2.00 | 0.00 | ||
Philippines | 1.00 | 0.00 |
You can edit the formula bar for the built in conditional column. First add a conditional column like this:
Then edit the formula bar so it looks like this:
Otherwise, click the button to create a new CUSTOM COLUMN in the Add Column tab, and paste this formula into the box:
if [Required]= 0 then null else if [Country] = "India" then Value.Divide([Available] - [DowntimeHrs]/7.5 - [Required],[Required]) else Value.Divide([Available] - [DowntimeHrs]/6.5 - [Required],[Required])
@Sriku UPDATE: Don't forget to set data type to number when you're done too.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
thx for pointing to the exception, your formula is 👍.
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Hi @Sriku
take a look at the following solution:
// Table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rZXLasMwEEV/JRi6G4NGb31Cu+reZBFooYYSAv1/qCxZtu/Y7iJ0ZRSdzOPeGXsYuvev8Xt8PMb7509HHTtSKj9VfXCsz549hZfuSkP3ev8Yb9OVrVeatNsce01cwbfb43bPv1gNIW0DLTmMqAOAhltuTQlJLHI9iXgKsM1RdIItn1CG3D5nb3acAq714J7M+r/R0Al9Qln064TyQPkzbTEln+VkTMp+9d49472D4i3ZKouTnqJqRWtWp12YSC6s3eaiDYKpXgSwIahledpOhEUOtnWHfDkGuTwsjeUpf7SKNIKLsCXSjF9wEQUSubQU23aJUDmzKxqlUGbOyCbQsjypZpLGWcl5FC/LrKeAyZFHEO3I4pp5xURAHWErDpuVA0VcFObsRdpJvI02F6GjaeYuoKvgZaUs76yd8/LfxUV81c3RotklFSs7D1ifjJwUjNgGdp3ltT6/59jsOFV3pnFtIVNsS4QfjoCF+rSYeESzwne9o1TKCGzaUMg/NN7GTXvJH8fXQvxmgAh6RF1/AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Available = _t, DowntimeHrs = _t, Required = _t, #"Percentage%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"Available", type number}, {"DowntimeHrs", type number}, {"Required", type number}, {"Percentage%", Percentage.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Percentage%"}),
#"Added Custom" = Table.AddColumn(#"Removed Columns", "Percentage",
each if [Country] = "India"
then ([Available] - ([DowntimeHrs]/7.5) - [Required])/[Required]
else ([Available] - ([DowntimeHrs]/6.5) - [Required])/[Required]),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Percentage", Percentage.Type}})
in
#"Changed Type1"
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Thanks for the solution. Now I am getting error due to infinity, How is overcome this issue. Please suggest
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
I am a learner to powerbi can you please help me in sharing in screen shot or share the logic applied in Powerbi
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
93 | |
90 | |
84 | |
70 | |
49 |
User | Count |
---|---|
141 | |
120 | |
112 | |
60 | |
58 |