Forum Discussion
Percentage visualization
- 1 year ago
Hi Cherry04 ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you Ashish_Excel for the prompt response.
I have created pbix file using sample data.Here are some steps followed to generate pbix:
1.Loaded sample data into Powerbi.
2.Created Relationships, you can check in attached pbix file.
3.Created DAX measures (Actualcost,Targetcost,%Diff).
4.Sorted MonthName by MonthNum to maintain chronological order.
You can go through the attached pbix file for your reference.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you. - 1 year ago
Hi Cherry04 ,
From your screenshots and DAX measure, it seems the issue lies in how the calculation behaves when specific months are selected. Your current measure:varTarvsAct = DIVIDE(SUM('Act'[Actual Cost]), SUM('Bud'[Target Cost])) - 1is context-sensitive. That means, when you filter by a specific month (e.g., February), the SUM('Act'[Actual Cost]) and SUM('Bud'[Target Cost]) only calculate for that selected month, and months that are not selected show as blank or misrepresented (often as 0%), which may explain the negative values you're seeing.
To fix this and always compare each month’s actual vs target independently, regardless of slicer selections, you can modify your DAX like this:
varTarvsAct = DIVIDE( CALCULATE(SUM('Act'[Actual Cost]), ALLSELECTED('Date'[Month])), CALCULATE(SUM('Bud'[Target Cost]), ALLSELECTED('Date'[Month])) ) - 1Or, if you're plotting data by month and need values for all months, you can try removing the month filter context from one side:
varTarvsAct = DIVIDE( SUM('Act'[Actual Cost]), CALCULATE(SUM('Bud'[Target Cost]), ALLEXCEPT('Bud', 'Bud'[Month])) ) - 1This will ensure that the line or column charts show accurate variance percentages for each month, even when only one month is selected in a slicer. Alternatively, you can build a disconnected table for month selection and use it only for slicer purposes while keeping calculations independent.
Hi Cherry04 ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.