Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi Community,
I have a slicer based on disconnected table that includes values A, B, C, D.
I have a table with transactional data that stores values A, B, C and D in separate columns.
Requirement is to create an new measure, let's call it F, that is going to return A, B, C, D OR sum of any combination of those columns.
I have created F as
Solved! Go to Solution.
The best approach would probably be to unpivot the columns A, B, C, and D so that you avoid writing this sort of measure entirely.
If they have to be separate columns, try this:
F =
VAR SelectedValues = VALUES ( DisconnectedTable[DisconnectedTable] )
RETURN
IF ( "A" IN SelectedValues, SUM ( [A] ) )
+ IF ( "B" IN SelectedValues, SUM ( [B] ) )
+ IF ( "C" IN SelectedValues, SUM ( [C] ) )
+ IF ( "D" IN SelectedValues, SUM ( [D] ) )
The best approach would probably be to unpivot the columns A, B, C, and D so that you avoid writing this sort of measure entirely.
If they have to be separate columns, try this:
F =
VAR SelectedValues = VALUES ( DisconnectedTable[DisconnectedTable] )
RETURN
IF ( "A" IN SelectedValues, SUM ( [A] ) )
+ IF ( "B" IN SelectedValues, SUM ( [B] ) )
+ IF ( "C" IN SelectedValues, SUM ( [C] ) )
+ IF ( "D" IN SelectedValues, SUM ( [D] ) )
@joanna-g2 Probably want something like:
F =
VAR UserSelections = DisconnectedTable[DisconnectedTable]
VAR __SumA = IF("A" IN UserSelections),SUM(A),BLANK())
VAR __SumB = IF("B" IN UserSelections),SUM(B) + __SumA,__SumA)
VAR __SumC = IF("C" IN UserSelections),SUM(C) + __SumB,__SumB)
VAR __SumD = IF("D" IN UserSelections),SUM(D) + __SumC,__SumC)
RETURN
__SumD
Hey @Greg_Deckler !
Thanks for your input! I think it is a very good approach.
There is one challange with the sollution you have suggested.
VAR UserSelections requires a single value for column in the DisconnectedTable. Do you have any suggestions how to work it around? I'm not able to use the Max/Min aggregation as it will pick up only one value from the slicer.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
51 | |
27 | |
23 | |
13 | |
8 |
User | Count |
---|---|
74 | |
52 | |
47 | |
16 | |
12 |