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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
RajaCSN
Helper III
Helper III

Need help on creating a Dax Formula

Hi All,

 

I have a situation as below:

 

My company sells a SET of four items, say SET_ABCD.  The set will contain Individual products A,B,C, and D.

We also sell the product A,B,C,D as individual pieces.

If I sell 500 numbers of SET_ABCD today, it means that I have sold 500 numbers of each of the four items.

When I aggregate the sales quantity for these individual items, the sale happenend as a SET should also be considered, and the expected results are as per the image below. 

 

RajaCSN_0-1645679008794.png

I tried with Parent-Child Hierarchy which only gives me a summation for Set_ABCD but not for the individual items.

 

Is it possible to create a calculated column or a measure for this purpose?

 

Any suggestion would be highly appreciated.

 

 

1 ACCEPTED SOLUTION

@RajaCSN , Only use final product in visual

 

First measure 
Qty = SUM(Data[QtySold]) 

final measure

Measure = sumx(SUMMARIZE('Product','Product'[Product],'Product'[Final Product], "_Sum", [Qty]),[_sum])
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

6 REPLIES 6
RajaCSN
Helper III
Helper III

Hi Amit,

Your solution is really cool. My bad, I tried with some complex logic here and there and you had just given me the "magic spell". 
Since the Quantity Sold values are picked from the invoice table, the total value is not reflecting the expected total.
RajaCSN_0-1645685142765.png

This being a Many-to-Many model, that's how it should happen. Is that right? Or is there a way around to get the total values too, as expected? (Timebeing, I can switch off the TOTAL and use this table).

 

Many thanks.

@RajaCSN , Only use final product in visual

 

First measure 
Qty = SUM(Data[QtySold]) 

final measure

Measure = sumx(SUMMARIZE('Product','Product'[Product],'Product'[Final Product], "_Sum", [Qty]),[_sum])
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you so much Amit.  This works like a charm! (BTW, I am now able to understand how the SUMMARIZE function can be used in similar scenarios!)

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Expected result: =
VAR newtable =
ADDCOLUMNS (
VALUES ( 'Product'[Product] ),
"individualqty",
CALCULATE (
IF (
SELECTEDVALUE ( 'Product'[Product] ) = "SET ABCD",
BLANK (),
SUM ( Data[QtySold] )
+ CALCULATE ( SUM ( Data[QtySold] ), 'Product'[Product] = "SET ABCD" )
)
)
)
RETURN
SUMX ( newtable, [individualqty] )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Many thanks for providing this solution. As such your solultion is working fine and I am getting the exact total value for the expected result column also. 

 

I am working on it to see if I can replace the hardcoded value of "SET ABCD" with another variable, as we have many such product sets. 

 

I shall seek your assistance again, if required.

 

Thank you so much for your time.

amitchandak
Super User
Super User

@RajaCSN , Your product dimension should be like this. You will join with your table on product M-M join and use final product in display

 

Product Final Product
A A
B B
C C
D D
SET_ABCD A
SET_ABCD B
SET_ABCD C
SET_ABCD D
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.