Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
Hi experts!!
I need your assistance with the following please:
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.
Solved! Go to Solution.
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])
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.
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])
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.
@rod2k21 Not sure exactly what you want but it sounds like this: Days of Supply - Microsoft Power BI Community
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
10 |