Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
How can I calculate online / offline % from my data by using a measure?
Table 1
Name | Unique | Status |
Apple | 1 | Offline |
Apple | 2 | Online |
Apple | 3 | Online |
Grapes | 4 | Online |
Grapes | 5 | Offline |
Grapes | 6 | Offline |
Carrot | 7 | Online |
Carrot | 8 | Online |
Table 2 (Result)
Name | Offline | Online | Grand Total |
Apple | 33% | 67% | 100% |
Grapes | 67% | 33% | 100% |
Carrot | 0% | 100% | 100% |
Grand Total | 38% | 63% | 100% |
Solved! Go to Solution.
Download PBIX file with these examples
Use these measures
Online =
VAR _Rows = CALCULATE(COUNTROWS('DataTable'), FILTER(ALL('DataTable'), 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
VAR _OnlineRows = CALCULATE(COUNTROWS('DataTable'), FILTER((ALL('DataTable')), 'DataTable'[Status] = "Online" && 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
RETURN
DIVIDE(_OnlineRows, _Rows) + 0
Offline =
VAR _Rows = CALCULATE(COUNTROWS('DataTable'), FILTER(ALL('DataTable'), 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
VAR _OfflineRows = CALCULATE(COUNTROWS('DataTable'), FILTER((ALL('DataTable')), 'DataTable'[Status] = "Offline" && 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
RETURN
DIVIDE(_OfflineRows, _Rows) + 0
Regards
Phil
Proud to be a Super User!
Try This measure.
Download PBIX file with these examples
Use these measures
Online =
VAR _Rows = CALCULATE(COUNTROWS('DataTable'), FILTER(ALL('DataTable'), 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
VAR _OnlineRows = CALCULATE(COUNTROWS('DataTable'), FILTER((ALL('DataTable')), 'DataTable'[Status] = "Online" && 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
RETURN
DIVIDE(_OnlineRows, _Rows) + 0
Offline =
VAR _Rows = CALCULATE(COUNTROWS('DataTable'), FILTER(ALL('DataTable'), 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
VAR _OfflineRows = CALCULATE(COUNTROWS('DataTable'), FILTER((ALL('DataTable')), 'DataTable'[Status] = "Offline" && 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name])))
RETURN
DIVIDE(_OfflineRows, _Rows) + 0
Regards
Phil
Proud to be a Super User!
| User | Count |
|---|---|
| 59 | |
| 47 | |
| 31 | |
| 18 | |
| 17 |
| User | Count |
|---|---|
| 77 | |
| 66 | |
| 46 | |
| 22 | |
| 22 |