Forum Discussion

WildIOM123's avatar
WildIOM123
Regular Visitor
2 years ago
Solved

Help with a rule please

Hi, I am looking for help with a rule set in Power BI which gives us the load factor of vessels. 

 

the current rule is: 

= Table.AddColumn(#"Grouped Rows", "Custom", each if [VesselName] = "Vessel 1" then 620 else if [VesselName] = "Vessel 2" then 900 else if [VesselName] = "Vessel 3" then 871 else null)

 

Vessel 2 increased it's capacity from 600 to 900 in 2024 so I need this to have 600 until 31/03/2024 and then 900 from 01/04/2024 - is there a way to insert this into the above? 

 

Thank you in advance 

  • Hi WildIOM123 ,

     

    You need to update your code to something similar to this:

     

    = Table.AddColumn(#"Grouped Rows", "Custom", each if [VesselName] = "Vessel 1" then 620 else if [VesselName] = "Vessel 2" and [Date] <=   #date(2024, 3, 31) then 600 else if [VesselName] = "Vessel 2" and[Date] >=   #date(2024, 4, 1) then 900 else if [VesselName] = "Vessel 3" then 871 else null)

     

    The [Date] is the column on the table that has the date you want to compare.

     

     

2 Replies

  • Hi WildIOM123 ,

     

    You need to update your code to something similar to this:

     

    = Table.AddColumn(#"Grouped Rows", "Custom", each if [VesselName] = "Vessel 1" then 620 else if [VesselName] = "Vessel 2" and [Date] <=   #date(2024, 3, 31) then 600 else if [VesselName] = "Vessel 2" and[Date] >=   #date(2024, 4, 1) then 900 else if [VesselName] = "Vessel 3" then 871 else null)

     

    The [Date] is the column on the table that has the date you want to compare.