Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi All
I need help on dax query as Current year and Current year +1 now working screenshot below and the query. If can provide the solution with dax it will be good
Solved! Go to Solution.
Hello @mdaamirkhan ,
you save NSM as a variable, but a variable is always static.
This means the moment you set the variable NSM the value is 10.
When you use this variable in the Calculate function, the value is already set to 10.
Try to use the DISTINCTCOUNT function in the CALCULATE function, then the result is evaluated in the right context:
Estimated revenue Current year +1 =
VAR thisYear = YEAR ( NOW () ) + 1
VAR val =
CALCULATE (
DISTINCTCOUNT ( Input_Contract_Report[months] ),
FILTER ( Input_Contract_Report, Input_Contract_Report[Active] = "Yes" ),
FILTER (
Input_Contract_Report,
Input_Contract_Report[End Date].[Year] = thisYear
),
ALLEXCEPT ( Invoice_Report, Invoice_Report[Contract Code] )
)
RETURN
--NSM
val * [Averge Revenue]
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Hello @mdaamirkhan ,
you save NSM as a variable, but a variable is always static.
This means the moment you set the variable NSM the value is 10.
When you use this variable in the Calculate function, the value is already set to 10.
Try to use the DISTINCTCOUNT function in the CALCULATE function, then the result is evaluated in the right context:
Estimated revenue Current year +1 =
VAR thisYear = YEAR ( NOW () ) + 1
VAR val =
CALCULATE (
DISTINCTCOUNT ( Input_Contract_Report[months] ),
FILTER ( Input_Contract_Report, Input_Contract_Report[Active] = "Yes" ),
FILTER (
Input_Contract_Report,
Input_Contract_Report[End Date].[Year] = thisYear
),
ALLEXCEPT ( Invoice_Report, Invoice_Report[Contract Code] )
)
RETURN
--NSM
val * [Averge Revenue]
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
its not working same issue. I have many-to-many relationship as well
what about this var thisYear = YEAR(NOW())+1
will it work in the query.
as per your query will it show 2022 value as well.
and if I want create table with a year use in slicer then how will used in the query
User | Count |
---|---|
91 | |
73 | |
68 | |
63 | |
55 |
User | Count |
---|---|
98 | |
89 | |
74 | |
67 | |
62 |