Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
I have two relevant tables that I'm working on;
My goal is to have a column in my Sales History table, which is a concatenation of all promotion types active for that product on any given day.
I still don't have a full understanding about how all of the formulas interact with each other. Below is a mix of pseudocode and my attempt at the actual code.
Active Promotions =
concatenate:
calculate(
DISTINCT('Promotions'[Type]),
filter('Promotions', 'Promotions'[ASIN] = earlier([ASIN])),
filter('Promotions', 'Promotions'[Country] = earlier([Country])),
filter('Promotions', 'Promotions'[Date] = earlier([Date])),
AllEXCEPT('Promotions','Promotions'[Type],'Promotions'[ASIN],'Promotions'[Country],'Promotions'[Date])
)
Here's an example of my promotions table:
ASIN | Country | Type | Date |
TestASIN | US | Coupon | 12/1/2021 |
TestASIN | US | Coupon | 12/2/2021 |
TestASIN | US | Coupon | 12/3/2021 |
TestASIN | US | Coupon | 12/4/2021 |
TestASIN | US | Lightning Deal | 12/1/2021 |
And here's an example of my Sales History table, with the desired column added at the end.
ASIN | Country | Date | QTY | Active Promotions |
TestASIN | US | 11/30/2021 | 100 | |
TestASIN | US | 12/1/2021 | 500 | Coupon, Lightning Deal |
TestASIN | US | 12/2/2021 | 120 | Coupon |
TestASIN | US | 12/3/2021 | 120 | Coupon |
TestASIN | US | 12/4/2021 | 120 | Coupon |
TestASIN | US | 12/5/2021 | 100 |
Solved! Go to Solution.
@Funk-E-Guy you can try this
_desired =
CALCULATE (
CALCULATE (
CONCATENATEX ( Promotions, Promotions[Type], ",", Promotions[Type], ASC ),
TREATAS (
SUMMARIZE (
SalesHistory,
SalesHistory[Country],
SalesHistory[Date],
SalesHistory[ASIN]
),
Promotions[Country],
Promotions[Date],
Promotions[ASIN]
)
)
)
@Funk-E-Guy you can try this
_desired =
CALCULATE (
CALCULATE (
CONCATENATEX ( Promotions, Promotions[Type], ",", Promotions[Type], ASC ),
TREATAS (
SUMMARIZE (
SalesHistory,
SalesHistory[Country],
SalesHistory[Date],
SalesHistory[ASIN]
),
Promotions[Country],
Promotions[Date],
Promotions[ASIN]
)
)
)
This seems to do the trick!
Thanks!
@Funk-E-Guy add a column using this:
Active Promotions =
VAR __tbl = CALCULATETABLE ( VALUES ('Text'[Type] ), ALLEXCEPT ( 'Text', 'Text'[ASIN],'Text'[Date],'Text'[Country] ) )
RETURN
CONCATENATEX ( __tbl, [Type], "," )
✨ Follow us on LinkedIn
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Funk-E-Guy can you please try this as a measure
Measure1= --assuming there is no relationship
VAR _country =
MAX ( 'Sales History'[Country] )
VAR _day =
MAX ( 'Sales History'[Day] )
VAR _product =
MAX ( 'Sales History'[Product] )
RETURN
CONCATENATEX (
FILTER (
Promotions,
Promotions[Country] = _country
&& Promotions[Day] = _day
&& Promotions[Product] = _product
),
Promotions[Type],
",",
Promotions[Type], ASC
)
---------------------------------------------------------------------------------------------
Measure2= --assuming there is a relationship
VAR _country =
MAX ( 'Sales History'[Country] )
VAR _day =
MAX ( 'Sales History'[Day] )
VAR _product =
MAX ( 'Sales History'[Product] )
RETURN
CONCATENATEX (
FILTER (
ALL(Promotions),
Promotions[Country] = _country
&& Promotions[Day] = _day
&& Promotions[Product] = _product
),
Promotions[Type],
",",
Promotions[Type], ASC
)
FYI I edited my post to include some sample data and desired output, in case that changes your answer. Is it possible to do this without the use of measures?
@Funk-E-Guy it will be easier if you provide some sample data and the expected output.
Read this post to get your answer quickly.
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Post edited
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
88 | |
77 | |
58 | |
43 | |
38 |