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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
rod2k21
New Member

Add values in a vertical way per product and determine week coverage

Hi experts!!

I need your assistance with the following please:

 

rod2k21_0-1668097662518.png

As you can see, I have a single table with info on the products. Requirement: I need to create a measure or something to know how many weeks my inventory ("UnidadesInventario") can cover (considering consumption by week "Consumo Sem").

For example, Coca is covered for two weeks because we have 5 available units and we are consuming 1 in the first week and 4 in the second week, so the result for Coca with this data...would be: 2.

I've tried SUMX function, however, I think I need something else because I have to control the number of weeks (or rows) and add some conditional sentences...

Any ideas, tips, or even code to share?

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rod2k21 ,

I have created a simple sapmle, please refer to it to see if it helps you.

Create measures.

 

 

Measure =
VAR _1 =
    CALCULATE (
        MAX ( 'Table'[UnidadesInventario] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[insumos] = SELECTEDVALUE ( 'Table'[insumos] )
        )
    )
VAR _sum =
    CALCULATE (
        SUM ( 'Table'[consumo Sem] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Sem] <= SELECTEDVALUE ( 'Table'[Sem] )
                && 'Table'[insumos] = SELECTEDVALUE ( 'Table'[insumos] )
        )
    )
RETURN
    IF ( _sum <= _1, 1, 0 )
result = COUNTAX(filter(ALL('Table'),'Table'[insumos]=SELECTEDVALUE('Table'[insumos])&&[Measure]=1),[Measure])

 

 

 

vpollymsft_0-1668147022645.png

Best Regards

Community Support Team _ Polly

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @rod2k21 ,

I have created a simple sapmle, please refer to it to see if it helps you.

Create measures.

 

 

Measure =
VAR _1 =
    CALCULATE (
        MAX ( 'Table'[UnidadesInventario] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[insumos] = SELECTEDVALUE ( 'Table'[insumos] )
        )
    )
VAR _sum =
    CALCULATE (
        SUM ( 'Table'[consumo Sem] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Sem] <= SELECTEDVALUE ( 'Table'[Sem] )
                && 'Table'[insumos] = SELECTEDVALUE ( 'Table'[insumos] )
        )
    )
RETURN
    IF ( _sum <= _1, 1, 0 )
result = COUNTAX(filter(ALL('Table'),'Table'[insumos]=SELECTEDVALUE('Table'[insumos])&&[Measure]=1),[Measure])

 

 

 

vpollymsft_0-1668147022645.png

Best Regards

Community Support Team _ Polly

 

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

 

Great, this is exactly what I needed! Thanks @Anonymous.

Greg_Deckler
Community Champion
Community Champion

@rod2k21 Not sure exactly what you want but it sounds like this: Days of Supply - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler , great reference, it helps!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.