Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Varadha123
Frequent Visitor

Dynamic ratio

Hi All,

Table:

QuarterCategoryItemsValuePrevious RatioCurrent RatioCalculation
Q3FurnitureTable10050%350%Table/Chair
Q3FurnitureChair20067%4%Chair/Sofa
Q3FurnitureSofa30033%14%Table/Sofa
Q3FurnitureDesk40050%3%Chair/Desk
Q4FurnitureTable70  Table/Chair
Q4FurnitureChair20  Chair/Sofa
Q4FurnitureSofa500  Table/Sofa
Q4FurnitureDesk700  Chair/Desk

 

In power bi, I have used Matrix table. Category as furniture , attributes  as undiscounted , items are Table,chair,desk in hieriarichy.

I have created a measere :  Table value = Divide(calculate(table(value),table[category]="Furniture", table[attributes]="Undiscounted",table [items]="table"],(calculate(table(value),table[category]="Furniture", table[attributes]="Undiscounted", table [items]="chair"

l want to calculate the percentage and the percentage value should be placed in the different rows.. Let's assume the table value should be placed in Chair row. So after created the table value measures I have created one more measure to consolidate

If( category = "Furniture",attributes="Undiscounted" items="Table" switch (true(), items="Chair",[Table value]

Question:

The dax is working fine. I want to dynamically change the value like in the slicers i have previous quarter and current quarter both as q1,q2,q3,q4

I want to create two ratios one is Previous ratio and current ration

If i click the previou slicer as Q3 and current slicer as Q4, the value in the previous ratio and current ratio should calculate the value based on the slicer selection 

Q3 table value should divide with the Q3 chair value and the value should be placed in the chair row of the previous ratio likewise Q4 table value should divide with the Q4 Chair value.

Instead of creating separate measures for Q3 and Q4 division measures is there any other way to create one measure that we can dynamically used the calculation for previous and current ratios.

Currently i have created separate division measures for previous and current ratio and consolidate with the another measure

Kindly help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi all,thanks for the quick reply, I'll add more.

Hi @Varadha123 ,

Correct me if I'm misunderstanding.

Assuming this is your data table

vzhouwenmsft_2-1738723646984.png

Use the following DAX expression to create a column

Column = Left([Calculation],FIND("/",[Calculation]) - 1)
Column2 = RIGHT([Calculation],LEN([Calculation]) - FIND("/",[Calculation]))

vzhouwenmsft_3-1738724082044.png

Use the following DAX expression to create two tables for slicers

current quarter = VALUES('Table'[Quarter])
previous quarter = VALUES('Table'[Quarter])

Use the following DAX expression to create  measures

Previous Ratio = 
VAR _quarter = SELECTEDVALUE('previous quarter'[Quarter])
VAR _numerator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column])),[Value])
VAR _denominator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column2])),[Value])
RETURN DIVIDE(_numerator,_denominator)
Current Ratio = 
VAR _quarter = SELECTEDVALUE('current quarter'[Quarter])
VAR _numerator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column])),[Value])
VAR _denominator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column2])),[Value])
RETURN DIVIDE(_numerator,_denominator)

Final output

vzhouwenmsft_5-1738724467284.png

 

Best Regards

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi all,thanks for the quick reply, I'll add more.

Hi @Varadha123 ,

Correct me if I'm misunderstanding.

Assuming this is your data table

vzhouwenmsft_2-1738723646984.png

Use the following DAX expression to create a column

Column = Left([Calculation],FIND("/",[Calculation]) - 1)
Column2 = RIGHT([Calculation],LEN([Calculation]) - FIND("/",[Calculation]))

vzhouwenmsft_3-1738724082044.png

Use the following DAX expression to create two tables for slicers

current quarter = VALUES('Table'[Quarter])
previous quarter = VALUES('Table'[Quarter])

Use the following DAX expression to create  measures

Previous Ratio = 
VAR _quarter = SELECTEDVALUE('previous quarter'[Quarter])
VAR _numerator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column])),[Value])
VAR _denominator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column2])),[Value])
RETURN DIVIDE(_numerator,_denominator)
Current Ratio = 
VAR _quarter = SELECTEDVALUE('current quarter'[Quarter])
VAR _numerator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column])),[Value])
VAR _denominator = SUMX(FILTER(ALL('Table'),[Quarter] = _quarter && [Items] = SELECTEDVALUE('Table'[Column2])),[Value])
RETURN DIVIDE(_numerator,_denominator)

Final output

vzhouwenmsft_5-1738724467284.png

 

Best Regards

 

danextian
Super User
Super User

Hi @Varadha123 

 

Can you clarify how you calculated the ratios? For instance, in row 1, the Current Ratio is listed as 350%, calculated as Table/Chair, but dividing Table by Chair (100/200) would give 50%. Additionally, your formula includes attributes and items columns that aren't present in your sample data. Providing a sample data set that accurately reflects your actual use case would help us understand your objective better and eliminate any guesswork regarding the extra columns.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Akash_Varuna
Super User
Super User

Hi @Varadha123  , Please try these steps

  • Create a Dynamic Measure: Use SELECTEDVALUE to fetch slicer selections for Previous Quarter and Current Quarter and calculate the respective Table and Chair values using CALCULATE for each quarter.
  • Calculate Ratios Dynamically: Create a measure to divide Table values by Chair values based on slicer selections and use SWITCH to display results for the selected quarter dynamically.
  • Ensure Row Placement: Add logic in the measure to display the calculated ratio only in the Chair row using a condition like IF(Table[Items] = "Chair", [Dynamic Ratio], BLANK()).
  • Integrate with Matrix Table: Add the measure to your matrix visual, ensuring slicers for Previous Quarter and Current Quarter are applied for dynamic ratio calculations.
    If this post helped please do give a kudos and accept this as a solution
    Thanks In Advance

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.