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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
abhijeetbehuria
Frequent Visitor

Dax Measure to get the Cumilative total Based on Part_Id

Thanks in Advance .

abhijeetbehuria_2-1670592040613.png

 

The above one is my source table .I want to get the output as  :-

abhijeetbehuria_3-1670592076937.png

 

From the Min date to the max date for the specific Part Id ,i want to get the cumilative total measure(not calculated column).

Also i want to find by using that measure ,when Part_Id has crossed 5 rupees .Like below :-

abhijeetbehuria_4-1670592397142.png

 

Please Help me .

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@abhijeetbehuria Try:

Cumulative Total Measure = 
  VAR __PartID = MAX('Table'[Part_Id])
  VAR __Date = MAX('Table'[Month Date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[Part ID] = __PartID && [Month Date] <= __Date)
  VAR __Result = SUMX(__Table, [Amount])
RETURN
  __Result

and

5 Rupee Measure = 
  VAR __PartID = MAX('Table'[Part_Id])
  VAR __Date = MAX('Table'[Month Date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[Part ID] = __PartID && [Month Date] <= __Date)
  VAR __WhileLoop =
    ADDCOLUMNS(
      __Table,
      "__Cumulative", SUMX(FILTER(__Table, [Month Date] <= EARLIER([Month Date])),[Amount])
  VAR __Result = MINX(FILTER(__WhileLoop, __Cumulative >= 5), [Month Date])
RETURN
  __Result


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...

View solution in original post

@abhijeetbehuria Sorry, missed a )

5 Rupee Measure = 
  VAR __PartID = MAX('Table'[Part_Id])
  VAR __Date = MAX('Table'[Month Date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[Part ID] = __PartID && [Month Date] <= __Date)
  VAR __WhileLoop =
    ADDCOLUMNS(
      __Table,
      "__Cumulative", SUMX(FILTER(__Table, [Month Date] <= EARLIER([Month Date])),[Amount])
    )
  VAR __Result = MINX(FILTER(__WhileLoop, __Cumulative >= 5), [Month Date])
RETURN
  __Result


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...

View solution in original post

9 REPLIES 9
abhijeetbehuria
Frequent Visitor

Yes I got the Result .I need to use squre bracket around that to get the result .Thank You so much man.

abhijeetbehuria
Frequent Visitor

Can i apply Filter like Month ,Year ,Quarter to this Measure 

@abhijeetbehuria Should be able to since using ALLSELECTED instead of ALL. ALLSELECTED should keep any filters external to the visual itself.



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...
abhijeetbehuria
Frequent Visitor

Thank You so much

 

Greg_Deckler
Community Champion
Community Champion

@abhijeetbehuria Try:

Cumulative Total Measure = 
  VAR __PartID = MAX('Table'[Part_Id])
  VAR __Date = MAX('Table'[Month Date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[Part ID] = __PartID && [Month Date] <= __Date)
  VAR __Result = SUMX(__Table, [Amount])
RETURN
  __Result

and

5 Rupee Measure = 
  VAR __PartID = MAX('Table'[Part_Id])
  VAR __Date = MAX('Table'[Month Date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[Part ID] = __PartID && [Month Date] <= __Date)
  VAR __WhileLoop =
    ADDCOLUMNS(
      __Table,
      "__Cumulative", SUMX(FILTER(__Table, [Month Date] <= EARLIER([Month Date])),[Amount])
  VAR __Result = MINX(FILTER(__WhileLoop, __Cumulative >= 5), [Month Date])
RETURN
  __Result


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...
Anonymous
Not applicable

Sir Please help me to Understand these two measure. I got the solution but not be able to understand it. It's my humble request. 

abhijeetbehuria_0-1670594403459.png

It's giving me Error .

 

@abhijeetbehuria Sorry, missed a )

5 Rupee Measure = 
  VAR __PartID = MAX('Table'[Part_Id])
  VAR __Date = MAX('Table'[Month Date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[Part ID] = __PartID && [Month Date] <= __Date)
  VAR __WhileLoop =
    ADDCOLUMNS(
      __Table,
      "__Cumulative", SUMX(FILTER(__Table, [Month Date] <= EARLIER([Month Date])),[Amount])
    )
  VAR __Result = MINX(FILTER(__WhileLoop, __Cumulative >= 5), [Month Date])
RETURN
  __Result


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, this is working

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.