March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
Hi All,
I'm struggling with approach to calculate revenue per "dynamic" category which is based on period slicer selection. In case month granularity appears on chart show revenue per category monthly, if quarter - show revenue (sum of all revenue in quarter) per category, if year - show revenue (sum of all revenue in year) per category.
Have fact table with monthly granularity and relation to date table on date filelds.
Is it even possible to calculate such logic in Power BI?
Sample of data
Account | Date | Amount |
1111 | 1/1/2022 | $ 100 |
1111 | 2/1/2022 | $ 300 |
1111 | 3/1/2022 | $ 200 |
1111 | 4/1/2022 | $ 100 |
1111 | 5/1/2022 | $ 600 |
1111 | 6/1/2022 | $ 200 |
1111 | 7/1/2022 | $ 300 |
2222 | 1/1/2022 | $ 600 |
2222 | 2/1/2022 | $ 400 |
2222 | 3/1/2022 | $ 500 |
2222 | 4/1/2022 | $ 400 |
2222 | 5/1/2022 | $ 500 |
2222 | 6/1/2022 | $ 600 |
2222 | 7/1/2022 | $ 700 |
2222 | 8/1/2022 | $ 600 |
categoty values
small | mid | large |
<= 300 | > 300 <= 1000 | > 1000 |
Expected result
monthly aggregation
quarter aggregation
in case of year aggregation
Solved! Go to Solution.
@bsas , You need to consider Dynamic Segmentation, but buckets will static
Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...
Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k
Hi @bsas ,
I think you want to show two legends [Category] and [Amount] in Stacked column chart in Power BI. Currently, Power BI doesn't support us to add two legends directly. Here I suggest you to try Small multiples function.
Data model:
Measure:
Amount by Category =
SWITCH (
SELECTEDVALUE ( Category[Category] ),
"Small",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Mid",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 1000
&& CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Large",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 1000,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @bsas ,
I think you want to show two legends [Category] and [Amount] in Stacked column chart in Power BI. Currently, Power BI doesn't support us to add two legends directly. Here I suggest you to try Small multiples function.
Data model:
Measure:
Amount by Category =
SWITCH (
SELECTEDVALUE ( Category[Category] ),
"Small",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Mid",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 1000
&& CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Large",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 1000,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@bsas , You need to consider Dynamic Segmentation, but buckets will static
Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...
Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k
Thank you @amitchandak ! I was moving in similar direction but your article inspired on new idea. At the end for my case I created separate table with ID and Label fields then created measure using switch and sumx.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |