The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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] ) )
@Anonymous 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.
User | Count |
---|---|
25 | |
10 | |
8 | |
7 | |
6 |
User | Count |
---|---|
32 | |
12 | |
10 | |
10 | |
9 |