Forum Discussion
DAX formule need help
- Anonymous4 years ago
Hi Anonymous and Greg_Deckler ,
I have finaly the solution. The issue was that there were no ratio between the table KPI and Date table. So I fixed this with the following formule.
_YTD_Target_Gauge = VAR KWARTAAL = SWITCH( TRUE(), [Business_date (current)] >= DATE(YEAR([Business_date (current)]),1,1) && [Business_date (current)] <= DATE(YEAR([Business_date (current)]),3,31), "Q1", [Business_date (current)] >= DATE(YEAR([Business_date (current)]),4,1) && [Business_date (current)] <= DATE(YEAR([Business_date (current)]),6,30), "Q2", [Business_date (current)] >= DATE(YEAR([Business_date (current)]),7,1) && [Business_date (current)] <= DATE(YEAR([Business_date (current)]),9,30), "Q3", [Business_date (current)] >= DATE(YEAR([Business_date (current)]),10,1) && [Business_date (current)] <= DATE(YEAR([Business_date (current)]),12,31), "Q4") VAR GMID = CALCULATE((SUM('Fact Target'[amt_lower_limit]) + SUM('Fact Target'[amt_upper_limit])) / 2,LEFT('Dim Kpi'[kpi_name],2) = KWARTAAL) VAR EINDKWARTAAL = DATEDIFF(DATE(YEAR([Business_date (current)]),1,1),ENDOFQUARTER('Dim Kpi'[dat_end]),DAY) VAR YTDDAGEN = DATEDIFF(DATE(YEAR([Business_date (current)]),1,1),[Business_date (current)],DAY) RETURN GMID*(YTDDAGEN/EINDKWARTAAL)And then another formule which Rico gave me:
TGT_Gauge = SUMX('Dim Kpi',[_YTD_Target_Gauge])Thank you guys to thinking about this issue!
Anonymous This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Hi Greg_Deckler ,
Thanks for quick response! Unfortnetuly my situation is a little bit complex which I still cannot get the value I want.
In mine situatie I use 3 differents tables see formule below. I really dont how to fix this.
_YTD Target_test1 =
VAR GMID = ([_KPI Lower Limit] + [_KPI Upper Limit]) / 2 //From FACT_Target table
VAR EINDKWARTAAL = DATEDIFF(DATE(YEAR([Business_date (current)]),1,1),ENDOFQUARTER('Dim Kpi'[dat_end]),DAY) //BusinessDate is from Snapshot table and Dim KPI is another table
VAR YTDDAGEN = DATEDIFF(DATE(YEAR([Business_date (current)]),1,1),[Business_date (current)],DAY)
RETURN
GMID * YTDDAGEN/EINDKWARTAAL
- Greg_Deckler4 years agoCommunity Champion
Anonymous Going to need more information then like sample data, relationships, etc.
Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.