Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Solved! Go to Solution.
@Evelin_ From the DAX code I can spot couple of mistakes. You are using Database table reference inside CALCULATE which is respecting the existing Filter Context so before it can be filtered for BP and SS it already gets filtered by whatever is the active Filter Context and the table returned by FILTER will be empty, try this instead:
CALCULATE (
SUM ( Database[Volume in UC] ),
Database[Version] = "BP"
&& Database[xxx] = "SS"
)
The above will ensure it ignores the existing Filter context on these 2 columns.
And if you don't want to overwrite the existing filter context on Version and XXX then use this:
CALCULATE (
SUM ( Database[Volume in UC] ),
KEEPFILTERS ( Database[Version] = "BP" && Database[xxx] = "SS" )
)
hi @Evelin_ ,
try like:
Measure =
VAR 1BP=
Calculate(
SUM(Database[Volume in UC]),
Filter(
Database,
Database[Version] = "BP"
&& Database[xxx] = "SS"
)
VAR 2BP=
Calculate(
SUM(Database[Volume in UC]),
Database[Version] = "BP"
)
VAR 3SHARE= divide (1BP , 2BP ) - 1
RETURN 3SHARE
@Evelin_
You need to use Dax Formatter
VAR BP_1 =
CALCULATE (
SUM ( Database[Volume in UC] ),
FILTER ( Database, Database[Version] = "BP" && Database[xxx] = "SS" )
)
VAR BP_2 =
CALCULATE ( SUM ( Database[Volume in UC] ), Database[Version] = "BP" )
VAR SHARE_3 =
DIVIDE ( BP_1, BP_2, -1 )
VAR ACT_1 =
CALCULATE (
SUM ( Database[Volume in UC] ),
FILTER ( Database, Database[Version] = "ACT" && Database[xxx] = "SS" )
)
VAR ACT_2 =
CALCULATE ( SUM ( Database[Volume in UC] ), Database[Version] = "ACT" )
VAR SHARE_4 =
DIVIDE ( ACT_1, ACT_2, -1 )
RETURN
SHARE_3 - SHARE_4
Best Regards,
Dangar
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Evelin_
You need to use Dax Formatter
VAR BP_1 =
CALCULATE (
SUM ( Database[Volume in UC] ),
FILTER ( Database, Database[Version] = "BP" && Database[xxx] = "SS" )
)
VAR BP_2 =
CALCULATE ( SUM ( Database[Volume in UC] ), Database[Version] = "BP" )
VAR SHARE_3 =
DIVIDE ( BP_1, BP_2, -1 )
VAR ACT_1 =
CALCULATE (
SUM ( Database[Volume in UC] ),
FILTER ( Database, Database[Version] = "ACT" && Database[xxx] = "SS" )
)
VAR ACT_2 =
CALCULATE ( SUM ( Database[Volume in UC] ), Database[Version] = "ACT" )
VAR SHARE_4 =
DIVIDE ( ACT_1, ACT_2, -1 )
RETURN
SHARE_3 - SHARE_4
Best Regards,
Dangar
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi @Evelin_ ,
try like:
Measure =
VAR 1BP=
Calculate(
SUM(Database[Volume in UC]),
Filter(
Database,
Database[Version] = "BP"
&& Database[xxx] = "SS"
)
VAR 2BP=
Calculate(
SUM(Database[Volume in UC]),
Database[Version] = "BP"
)
VAR 3SHARE= divide (1BP , 2BP ) - 1
RETURN 3SHARE
"How Can I write this dax properly?" What kind of help do you need here? Optimization or the results are incorrect?
Hello!
the result is incorrect and I tried to fix it but I think I miss something, some digns or anything that can cause error 😞
Thank you for your answer!
Evelin
@Evelin_ From the DAX code I can spot couple of mistakes. You are using Database table reference inside CALCULATE which is respecting the existing Filter Context so before it can be filtered for BP and SS it already gets filtered by whatever is the active Filter Context and the table returned by FILTER will be empty, try this instead:
CALCULATE (
SUM ( Database[Volume in UC] ),
Database[Version] = "BP"
&& Database[xxx] = "SS"
)
The above will ensure it ignores the existing Filter context on these 2 columns.
And if you don't want to overwrite the existing filter context on Version and XXX then use this:
CALCULATE (
SUM ( Database[Volume in UC] ),
KEEPFILTERS ( Database[Version] = "BP" && Database[xxx] = "SS" )
)
Many many thanks, it worked!!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
21 | |
20 | |
19 | |
13 | |
12 |
User | Count |
---|---|
41 | |
29 | |
23 | |
22 | |
22 |