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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
DataHero
Helper I
Helper I

GENERATESERIES by boundaries

Hi forum,

 

I have a question to you regarding following scenario: 

Table Dim_SKR4_Account_Group contains financial account groups, defined by ranges.

DataHero_0-1733842039924.png


Dim_SKR4_Chart_of_Accounts contains all accounts (unique):

DataHero_1-1733842166255.png


To relate both, I want to create following mapping table Mapp_Populated_Account_Range:

DataHero_2-1733842211560.png

Here the code:
Mapp_Populated_Account_Range =
VAR MinAccount = MINX('Dim_SKR4_Account_Group','Dim_SKR4_Account_Group'[KontoNrUntergrenze])
VAR MaxAccount = MAXX('Dim_SKR4_Account_Group','Dim_SKR4_Account_Group'[KontoNrObergrenze])
RETURN
GENERATE (
    SELECTCOLUMNS(
        'Dim_SKR4_Account_Group',
        "Account lower boundary", [KontoNrUntergrenze],
        "Account upper boundary", [KontoNrObergrenze]
    ),
    GENERATESERIES(MinAccount, MaxAccount, 1)
)




As you can see, DAX doesnt apply the boundaries.
Therefore I get duplicates.

I worked with CALENDAR() before and didnt face this problem.
I thought GENERATESERIES would work in a similar way.

Is there a way to fix the DAX code or do I have to choose a workaround?
Before this mapping logic was implemented via conditional merge in PQ, but I want to do it in DAX, if possible.

 

Many thanks,
DataHero

1 ACCEPTED SOLUTION
DataHero
Helper I
Helper I

Hi forum,

I found a solution now for my specific case:

Mapp_Populated_Account_Series =

GENERATE (

    SELECTCOLUMNS (

        'Dim_SKR4_Account_Group',

        "Account lower boundary", Dim_SKR4_Account_Group[KontoNrUntergrenze],

        "Account upper boundary", Dim_SKR4_Account_Group[KontoNrObergrenze]

    ),

    GENERATESERIES (

        [Account lower boundary],

        [Account upper boundary],

        1

    )

)

 


When you use GENERATESERIES, attention is to be paid in case you want to rename columns withing this code. DAX can easily loose the context here.
To avoid errors, the code is to be written as for the column “test” in case of renaming.

 

Mapp_Populated_Account_Series =

GENERATE (

    SELECTCOLUMNS (

        'Dim_SKR4_Account_Group',

        "test", Dim_SKR4_Account_Group[KontoNrUntergrenze],

       [KontoNrObergrenze]

    ),

    GENERATESERIES (

        [test],

        'Dim_SKR4_Account_Group'[KontoNrObergrenze],

        1

    )

)

 

)

 

To avoid problems, I recommend to rename already in PQ.

View solution in original post

3 REPLIES 3
DataHero
Helper I
Helper I

Hi forum,

I found a solution now for my specific case:

Mapp_Populated_Account_Series =

GENERATE (

    SELECTCOLUMNS (

        'Dim_SKR4_Account_Group',

        "Account lower boundary", Dim_SKR4_Account_Group[KontoNrUntergrenze],

        "Account upper boundary", Dim_SKR4_Account_Group[KontoNrObergrenze]

    ),

    GENERATESERIES (

        [Account lower boundary],

        [Account upper boundary],

        1

    )

)

 


When you use GENERATESERIES, attention is to be paid in case you want to rename columns withing this code. DAX can easily loose the context here.
To avoid errors, the code is to be written as for the column “test” in case of renaming.

 

Mapp_Populated_Account_Series =

GENERATE (

    SELECTCOLUMNS (

        'Dim_SKR4_Account_Group',

        "test", Dim_SKR4_Account_Group[KontoNrUntergrenze],

       [KontoNrObergrenze]

    ),

    GENERATESERIES (

        [test],

        'Dim_SKR4_Account_Group'[KontoNrObergrenze],

        1

    )

)

 

)

 

To avoid problems, I recommend to rename already in PQ.

johnt75
Super User
Super User

The problem is that the MIN and MAX are being calculated without any filter or row context. Try

All accounts =
GENERATE (
    SELECTCOLUMNS (
        Dim_SKR4_Account_Group,
        Dim_SKR4_Account_Group[KontoNrUntergrenze],
        Dim_SKR4_Account_Group[KontoNrObergrenze]
    ),
    GENERATESERIES (
        Dim_SKR4_Account_Group[KontoNrUntergrenze],
        Dim_SKR4_Account_Group[KontoNrObergrenze]
    )
)
timalbers
Super User
Super User

Hi @DataHero 

if you only want to link the matching group to each Konto you may try to add a new custom column in Dim_SKR4_Chart_of_Accounts like this:

 

Gruppe = 
CALCULATE(
    MIN( Dim_SKR4_Account_Group[Kontengruppe] ),
    FILTER( Dim_SKR4_Account_Group, Dim_SKR4_Account_Group[KontoNrUntergrenze] <= Dim_SKR4_Chart_of_Accounts[KontoNr] ),
    FILTER( Dim_SKR4_Account_Group, Dim_SKR4_Account_Group[KontoNrObergrenze] >= Dim_SKR4_Chart_of_Accounts[KontoNr] )
)

 

Hope this helps!

 

Grüße

Tim 


—————————————————————————————
✔️ If my answer helped you, please consider marking it as a solution.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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