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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Split row based on if statement

Hi,

 

Im new to Power BI. I have the following table from a  .xslx file

 

Shkr_0-1611911590944.png

 

 I want to split this in to 12 periods, only when period is "0".  if period is 1 to 12 the row should just follow like this:

 

Shkr_1-1611911801147.png

 

 

1 ACCEPTED SOLUTION
Smauro
Solution Sage
Solution Sage

Hi @Anonymous,

 

using the advanced editor, you could try adding this in your code:

    #"Fix Amounts" = Table.ReplaceValue(PreviousStep,
        each if [Period] = 0 then [Amount] else nulleach [Amount]/12,
        Replacer.ReplaceValue, {"Amount"} ),
    #"Fix Periods" = Table.TransformColumns(#"Fix Amounts",
{{"Period"each if _ = 0 then {1..12else {_}, type list}}),
    #"Expanded Periods" = Table.ExpandListColumn(#"Fix Periods", "Period")
in
    #"Expanded Periods"

 

Replacing PreviousStep with your previous step's name.

 

 

Best,

Spyros




Spyros Mavroforos

Data Consultant


Find me on LinkedIn or drop me an email

eSpyros

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks Spyros! That worked well. The "Amount" column formatted into text and i had to replace Indexing step as last step obviously. 

Smauro
Solution Sage
Solution Sage

Hi @Anonymous,

 

using the advanced editor, you could try adding this in your code:

    #"Fix Amounts" = Table.ReplaceValue(PreviousStep,
        each if [Period] = 0 then [Amount] else nulleach [Amount]/12,
        Replacer.ReplaceValue, {"Amount"} ),
    #"Fix Periods" = Table.TransformColumns(#"Fix Amounts",
{{"Period"each if _ = 0 then {1..12else {_}, type list}}),
    #"Expanded Periods" = Table.ExpandListColumn(#"Fix Periods", "Period")
in
    #"Expanded Periods"

 

Replacing PreviousStep with your previous step's name.

 

 

Best,

Spyros




Spyros Mavroforos

Data Consultant


Find me on LinkedIn or drop me an email

eSpyros

Anonymous
Not applicable

Hi @smaru 

 

I want to modify this a little bit. What if i use "x" as a delimiter like this:

 

Shkr_0-1612338308069.png

 

 

In "period" column i type 5x36 meaning start at period 5, go for 36 periods. "Period" will have to go from 1-12 and "Year" has to be changed every 12 period.  

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.