The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I am a beginner in powerbi, please help me with enough detail to solve this scenario:
Suppose that I have several records in a table like these:
| Item | Status | Date |Semester |
|------| ------------ |------------|---------|
| C1 | Ready | 12/06/2024 | S1-2024 |
| C2 | In progress | 09/06/2024 | S1-2024 |
| C1 | In progress | 08/06/2024 | S1-2024 |
I need a bar chart that only shows the most recent status of all the items in a current period of time in this case "semester", in the example for S1-2024 the data table must be:
| Item | Status | Date |Semester |
|------| ------------ |------------|---------|
| C1 | Ready | 12/06/2024 | S1-2024 |
| C2 | In progress | 09/06/2024 | S1-2024 |
How can accomplish that?
Solved! Go to Solution.
Hi guys, finally based on this thread: https://stackoverflow.com/questions/78048985/dax-code-to-calculate-a-new-column-by-latest-date-categ... I have just created a calculated column as follows that marks with 1 to the latest date in semester related to the bd:
IsLatestDate =
VAR CurrentDate = 'ParchBD'[Date]
VAR CurrentSemester = 'ParchBD'[Semester]
VAR CurrentBDD = 'ParchBD'[BDD]
VAR CurrentStatus = 'ParchBD'[Status]
RETURN
IF(
CurrentDate = CALCULATE(MAX('ParchBD'[Date]), FILTER(ALL('ParchBD'), 'ParchBD'[Semester] = CurrentSemester &&'ParchBD'[BDD] = CurrentBDD)),
1,
0
)
Then I have created a calculated table that shows bdd, semester, status and date filtered by the latest date in the semester:
LatestStatusDate =
SUMMARIZE(
FILTER('ParchBD', 'ParchBD'[IsLatestDate] = 1),
'ParchBD'[BDD],
'ParchBD'[Semester],
'ParchBD'[Status],
'ParchBD'[Date]
)
Finally I dragged the field of the LatestStatusDate table to the visual to show only the latest status of each bd during the semester:
I hope all the cases are considered, as far as I verified this accomplish the goal.
Any suggestions are welcome.
Hi guys, finally based on this thread: https://stackoverflow.com/questions/78048985/dax-code-to-calculate-a-new-column-by-latest-date-categ... I have just created a calculated column as follows that marks with 1 to the latest date in semester related to the bd:
IsLatestDate =
VAR CurrentDate = 'ParchBD'[Date]
VAR CurrentSemester = 'ParchBD'[Semester]
VAR CurrentBDD = 'ParchBD'[BDD]
VAR CurrentStatus = 'ParchBD'[Status]
RETURN
IF(
CurrentDate = CALCULATE(MAX('ParchBD'[Date]), FILTER(ALL('ParchBD'), 'ParchBD'[Semester] = CurrentSemester &&'ParchBD'[BDD] = CurrentBDD)),
1,
0
)
Then I have created a calculated table that shows bdd, semester, status and date filtered by the latest date in the semester:
LatestStatusDate =
SUMMARIZE(
FILTER('ParchBD', 'ParchBD'[IsLatestDate] = 1),
'ParchBD'[BDD],
'ParchBD'[Semester],
'ParchBD'[Status],
'ParchBD'[Date]
)
Finally I dragged the field of the LatestStatusDate table to the visual to show only the latest status of each bd during the semester:
I hope all the cases are considered, as far as I verified this accomplish the goal.
Any suggestions are welcome.
Hi @suppportme ,
Here is my sample data:
You mentioned that you need to create bar charts, but I'm not sure how you intend to create them with this data, so I'll use the table visual object as an example. The exact steps are the same.
Use this DAX to create a measure:
Measure =
VAR _MAXDAY =
CALCULATE(
MAX('Table'[Date]),
ALLEXCEPT('Table', 'Table'[Item], 'Table'[Semester])
)
RETURN
IF(
MAX('Table'[Date]) = _MAXDAY,
1,
0
)
Please set the settings according to the following screenshot:
And the final output is as below:
The same steps apply to bar charts.
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Thank you so much for your help.
It works perfectly but the real situation is that I have to some way count all these values to show in a graph as I show you below, where you can see that exists count of bdd (I called item in my initial post). Currently it counts all the status of all the items in all dates, when I need just count distinct the latest ones in the period of semester.
I do not know how to apply your solution to this case. Apparently I need to filter as the solution that you gave me and then count them distinct. Could you help me please to see how to do that?
I am really thankful for your help.