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.
This is what my data looks like:
Please note this is just for category A. I have other categories as well. But all of them have channels and date and total orders etc. I want to calculate weekly sum for each category. However, I want to discount channel. I would like to show it in visual but the value of sum should be constant for all.
In the above case. 524+532+499+412+617 = 2584
I have this DAX:
Weekly Notification Sum =
VAR _max = MAXX(all(Consolidated), Consolidated[ Channel])
VAR _min = MAXX(ALL(Consolidated), Consolidated[Channel])
RETURN
CALCULATE(
SUM(Consolidated[Nudges]),
FILTER(Consolidated, Consolidated[ Channel] = _min || Consolidated[ Channel] = _max )
)
This one ofcourse doenst give me correct value. It takes max of each channel and then gives me that.
Tried many things but I am extremely clueless.
Edit:
This solution works fine until I add another column Channel into context.
Weekly Notification Sum =
VAR _Distinct_ =
SUMMARIZE (
Consolidated,
Consolidated[Type],
Consolidated[Date],
Consolidated[Total notifications]
)
RETURN
SUMX ( _Distinct_, Consolidated[Total notifications] )
To avoid counting the value multiple times, you can group the relevant columns before summing.
For example:
Weekly Notification Sum =
VAR _Distinct_ =
SUMMARIZE (
Consolidated,
Consolidated[Type],
Consolidated[Date],
Consolidated[Total notifications]
)
RETURN
SUMX ( _Distinct_, Consolidated[Total notifications] )
How do I make it not get affected by channel in the visual? When I add Channel it shows a different sum for each channel. I want it to show 2584 for all channels.
One approach would be to remove all filter context except the columns you're summarizing.
Try this, for example:
Weekly Notification Sum =
VAR _Distinct_ =
CALCULATETABLE (
SUMMARIZE (
Consolidated,
Consolidated[Type],
Consolidated[Date],
Consolidated[Total notifications]
),
ALLEXCEPT (
Consolidated,
Consolidated[Type],
Consolidated[Date],
Consolidated[Total notifications]
)
)
RETURN
SUMX ( _Distinct_, Consolidated[Total notifications] )
User | Count |
---|---|
83 | |
83 | |
37 | |
34 | |
32 |
User | Count |
---|---|
92 | |
79 | |
61 | |
51 | |
51 |