Forum Discussion
Divide function on two different date field | Calculate quota
- 3 years ago
This article (Using USERELATIONSHIP in DAX - SQLBI) is similar to your scenario. It also has two date fields in a table. Please read it to get some basic ideas first. Then you can try the following steps:
1. Add a Date or Calendar table to your model. Make sure it covers all dates that may appear in Creation Date and Changed On Date columns. How to Create Date Tables in Power BI Tutorial | DataCamp
2. Build relationships from Date table's Date column to Creation Date and Changed On Date in Fact table. As only one relationship can be active between two tables, one relationship is active and the other one is inactive.
3. Use Date table's Date column on X-axis of line charts.
4. Assume the active relationship is between Date[Date] and 'Fact Table'[Creation Date], you can create the following measures. USERELATIONSHIP function is used to activate an inactive relationship in calculation. I assume that you use Count for aggregation.
Number of Incoming = COUNT ( 'Fact Table'[Item] )Number of Cancelled = CALCULATE ( COUNT ( 'Fact Table'[Item] ), USERELATIONSHIP ( 'Date'[Date], 'Fact Table'[Changed On Date] ) )5. Add above measures to Y-axis of the line chart.
6. Create the third measure for the ratio. Add it to the line chart.
Ratio = DIVIDE ( [Number of Cancelled], [Number of Incoming] )Hope this helps.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
This article (Using USERELATIONSHIP in DAX - SQLBI) is similar to your scenario. It also has two date fields in a table. Please read it to get some basic ideas first. Then you can try the following steps:
1. Add a Date or Calendar table to your model. Make sure it covers all dates that may appear in Creation Date and Changed On Date columns. How to Create Date Tables in Power BI Tutorial | DataCamp
2. Build relationships from Date table's Date column to Creation Date and Changed On Date in Fact table. As only one relationship can be active between two tables, one relationship is active and the other one is inactive.
3. Use Date table's Date column on X-axis of line charts.
4. Assume the active relationship is between Date[Date] and 'Fact Table'[Creation Date], you can create the following measures. USERELATIONSHIP function is used to activate an inactive relationship in calculation. I assume that you use Count for aggregation.
Number of Incoming = COUNT ( 'Fact Table'[Item] )
Number of Cancelled =
CALCULATE (
COUNT ( 'Fact Table'[Item] ),
USERELATIONSHIP ( 'Date'[Date], 'Fact Table'[Changed On Date] )
)
5. Add above measures to Y-axis of the line chart.
6. Create the third measure for the ratio. Add it to the line chart.
Ratio = DIVIDE ( [Number of Cancelled], [Number of Incoming] )
Hope this helps.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Great, that is the solution! Thank you