Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone,
so initially i had the requirement of distributing specific yearly values for 2022 and 2023 on an existing measure. The solution for that issue also seemed to work on my side as expected. Now i have the requirement to overwrite the previously added values for every single month with another value if specific conditions are met.
To give you a little bit more understanding, this is how the implemented and working code for a even monthly distribution looks like:
VAR AddCount2022 = 26
VAR AddCount2023 = 27.5
RETURN
SUMX (
SUMMARIZE ( 'v_DimDate', 'v_DimDate'[Year], 'v_DimDate'[Month]),
VAR __Market =
CALCULATE (
SUM ( 'v_factMarketCece'[Count] ),
'v_DimMarketCeceCompany'[Group] = "Market"
)
RETURN
IF (
HASONEVALUE ( 'v_DimMarketCeceActivity'[ChartType] ),
SWITCH ( 'v_DimDate'[Year], 2022, AddCount2022, 2023, AddCount2023 ) + __Market
)
)
This perfectly adds 26 addtional pieces to the existing total if the year 2022 is selected and 27,5 pieces if 2023 is selected.
Now another Dimension called "Sizes" comes into play. The total additional value for 2022 of 312 pcs (26 pcs x 12 months = 312) should now be distributed differently according to the affected sizes. Also those addtional values for sizes should only be displayed for the years 2022 and 2023.
For this purpose i`ve created the following DAX - Code. While in my Editor no error is shown i cannot use the measure in my model to evaluate. Instead i get an error message. I know this is rather complex due to alot of conditional programming and changing values but i would appreciate your help. If something is still unclear please let me know.
This is the current state i`m stuck atm:
VAR SizeClass13to15 = 91
VAR SizeClass15to17 = 207
VAR SizeClass17to20 = 7
VAR SizeClass20andOver = 7
RETURN
SUMX(
SUMMARIZECOLUMNS(
'v_DimMarketProduct'[Size],
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">13 -15"
),
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">15 -17"
),
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">17 -20"
),
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">20 & Over"
)
),
VAR __Market =
CALCULATE(
SUM( 'v_factMarket'[Count] ),
'v_DimMarketCompany'[Group] = "Market"
)
RETURN
IF(
HASONEVALUE( 'v_DimMarketActivity'[ChartType] ),
SWITCH(
'v_DimMarketProduct'[Size],
">13 -15", SizeClass13to15,
">15 -17", SizeClass15to17,
">17 -20", SizeClass17to20,
">20 & Over", SizeClass20andOver
) + __Market
)
)
SUMMARIZECOLUMNS(
'v_DimMarketProduct'[Size],
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">13 -15"
),
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">15 -17"
),
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">17 -20"
),
FILTER(
'v_DimMarketProduct',
'v_DimMarketProduct'[Size] = ">20 & Over"
)
)
Apart from being rather verbose these filters also contradict each other. Were you planning to add calculated columns in your table variable?
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |